Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-03-20 11:55:40
Exec Total Coverage
Lines: 7937 12125 65.5%
Functions: 69 106 65.1%
Branches: 4990 9903 50.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23 #include <fmt/format.h>
24
25
26 #include "metadata/sigs/devsig.h.sig"
27 #include "metadata/sigs/compilersig.h.sig"
28 #include "metadata/versionsig.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "qst.h"
35 //#include "zquest.h"
36 #include "defdata.h"
37 #include "subscr.h"
38 #include "font.h"
39 #include "zc_custom.h"
40 #include "sfx.h"
41 #include "md5.h"
42 #include "ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 //FFScript FFCore;
46 extern FFScript FFCore;
47 extern ZModule zcm;
48 extern zcmodule moduledata;
49 extern uint8_t __isZQuest;
50 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
51 extern particle_list particles;
52 extern void setZScriptVersion(int32_t s_version);
53 //FFSCript FFEngine;
54
55 int32_t temp_ffscript_version = 0;
56 static bool read_ext_zinfo = false, read_zinfo = false;
57 static bool loadquest_report = false;
58 static char const* loading_qst_name = NULL;
59 static byte loading_qst_num = 0;
60
61 #ifdef _MSC_VER
62 #define strncasecmp _strnicmp
63 #endif
64
65 #ifndef _AL_MALLOC
66 #define _AL_MALLOC(a) _al_malloc(a)
67 #define _AL_FREE(a) _al_free(a)
68 #endif
69
70 using std::string;
71 using std::pair;
72
73 // extern bool debug;
74 extern int32_t hero_animation_speed; //lower is faster animation
75 extern std::vector<mapscr> TheMaps;
76 extern zcmap *ZCMaps;
77 extern MsgStr *MsgStrings;
78 extern DoorComboSet *DoorComboSets;
79 extern dmap *DMaps;
80 extern newcombo *combobuf;
81 extern byte *colordata;
82 //extern byte *tilebuf;
83 extern tiledata *newtilebuf;
84 extern byte *trashbuf;
85 extern itemdata *itemsbuf;
86 extern wpndata *wpnsbuf;
87 extern comboclass *combo_class_buf;
88 extern guydata *guysbuf;
89 extern ZCHEATS zcheats;
90 extern zinitdata zinit;
91 extern char palnames[MAXLEVELS][17];
92 extern int32_t memrequested;
93 extern char *byte_conversion(int32_t number, int32_t format);
94 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
95 29 string zScript;
96 29 std::map<int32_t, script_slot_data > ffcmap;
97 29 std::map<int32_t, script_slot_data > globalmap;
98 29 std::map<int32_t, script_slot_data > genericmap;
99 29 std::map<int32_t, script_slot_data > itemmap;
100 29 std::map<int32_t, script_slot_data > npcmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
29 std::map<int32_t, script_slot_data > ewpnmap;
102 29 std::map<int32_t, script_slot_data > lwpnmap;
103 29 std::map<int32_t, script_slot_data > playermap;
104 29 std::map<int32_t, script_slot_data > dmapmap;
105 29 std::map<int32_t, script_slot_data > screenmap;
106 29 std::map<int32_t, script_slot_data > itemspritemap;
107 29 std::map<int32_t, script_slot_data > comboscriptmap;
108 void free_newtilebuf();
109 bool combosread=false;
110 bool mapsread=false;
111 bool fixffcs=false;
112 bool fixpolsvoice=false;
113
114
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
115
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
116
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
117
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
118
119 char qstdat_string[2048] = { 0 };
120
121 static zinfo* load_tmp_zi = NULL;
122
123 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
124 const byte clavio[9]={97,109,111,110,103,117,115,0};
125
126 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
127 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
128
129 extern combo_alias combo_aliases[MAXCOMBOALIASES];
130 extern combo_pool combo_pools[MAXCOMBOPOOLS];
131 const char *qst_error[] =
132 {
133 "OK","File not found","Invalid quest file",
134 "Version not supported","Obsolete version",
135 "Missing new data" , /* but let it pass in ZQuest */
136 "Internal error occurred", "Invalid password",
137 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
138 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
139 };
140
141 //for legacy quests -DD
142 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
143 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
144 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
145 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
146 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
147 };
148
149 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
150
151
152 void delete_combo_aliases()
153 {
154 for(int32_t j(0); j<256; j++)
155 {
156 if(combo_aliases[j].combos != NULL)
157 {
158 delete[] combo_aliases[j].combos;
159 combo_aliases[j].combos=NULL;
160 }
161
162 if(combo_aliases[j].csets != NULL)
163 {
164 delete[] combo_aliases[j].csets;
165 combo_aliases[j].csets=NULL;
166 }
167 }
168
169 }
170
171 char *byte_conversion(int32_t number, int32_t format)
172 {
173 static char num_str[40];
174
175 if(format==-1) //auto
176 {
177 format=1; //bytes
178
179 if(number>1024)
180 {
181 format=2; //kilobytes
182 }
183
184 if(number>1024*1024)
185 {
186 format=3; //megabytes
187 }
188
189 if(number>1024*1024*1024)
190 {
191 format=4; //gigabytes (dude, what are you doing?)
192 }
193 }
194
195 switch(format)
196 {
197 case 1: //bytes
198 sprintf(num_str,"%db",number);
199 break;
200
201 case 2: //kilobytes
202 sprintf(num_str,"%.2fk",float(number)/1024);
203 break;
204
205 case 3: //megabytes
206 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
207 break;
208
209 case 4: //gigabytes
210 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
211 break;
212
213 default:
214 exit(1);
215 break;
216 }
217
218 return num_str;
219 }
220
221 406 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
222 {
223 static char num_str1[40];
224 static char num_str2[40];
225 static char num_str[80];
226
227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format1==-1) //auto
228 {
229 406 format1=1; //bytes
230
231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number1>1024)
232 {
233 406 format1=2; //kilobytes
234 406 }
235
236
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 116 times.
406 if(number1>1024*1024)
237 {
238 116 format1=3; //megabytes
239 116 }
240
241
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number1>1024*1024*1024)
242 {
243 format1=4; //gigabytes (dude, what are you doing?)
244 }
245 406 }
246
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format2==-1) //auto
248 {
249 406 format2=1; //bytes
250
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number2>1024)
252 {
253 406 format2=2; //kilobytes
254 406 }
255
256
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 377 times.
406 if(number2>1024*1024)
257 {
258 377 format2=3; //megabytes
259 377 }
260
261
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number2>1024*1024*1024)
262 {
263 format2=4; //gigabytes (dude, what are you doing?)
264 }
265 406 }
266
267
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
406 switch(format1)
268 {
269 case 1: //bytes
270 sprintf(num_str1,"%db",number1);
271 break;
272
273 case 2: //kilobytes
274 290 sprintf(num_str1,"%.2fk",float(number1)/1024);
275 290 break;
276
277 case 3: //megabytes
278 116 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
279 116 break;
280
281 case 4: //gigabytes
282 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
283 break;
284
285 default:
286 exit(1);
287 break;
288 }
289
290
2/5
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 377 times.
✗ Branch 4 not taken.
406 switch(format2)
291 {
292 case 1: //bytes
293 sprintf(num_str2,"%db",number2);
294 break;
295
296 case 2: //kilobytes
297 29 sprintf(num_str2,"%.2fk",float(number2)/1024);
298 29 break;
299
300 case 3: //megabytes
301 377 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
302 377 break;
303
304 case 4: //gigabytes
305 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
306 break;
307
308 default:
309 exit(1);
310 break;
311 }
312
313 406 sprintf(num_str, "%s/%s", num_str1, num_str2);
314 406 return num_str;
315 }
316
317 char *ordinal(int32_t num)
318 {
319 static const char *ending[4] = {"st","nd","rd","th"};
320 static char ord_str[8];
321
322 char *end;
323 int32_t t=(num%100)/10;
324 int32_t n=num%10;
325
326 if(n>=1 && n<4 && t!=1)
327 end = (char *)ending[n-1];
328 else
329 end = (char *)ending[3];
330
331 sprintf(ord_str,"%d%s",num%10000,end);
332 return ord_str;
333 }
334
335 29 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
336 {
337 int32_t ret;
338 29 *version=0;
339 29 *build=0;
340 29 byte temp_map_count=map_count;
341 byte temp_midi_flags[MIDIFLAGS_SIZE];
342 29 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
343
344 zquestheader tempheader;
345
346
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
347 {
348 return qe_invalid;
349 }
350
351 29 ret=readheader(f, &tempheader, true);
352
353
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(ret)
354 {
355 return ret;
356 }
357
358 29 map_count=temp_map_count;
359 29 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
360 29 *version=tempheader.zelda_version;
361 29 *build=tempheader.build;
362 29 return 0;
363 29 }
364
365
366 29 bool find_section(PACKFILE *f, int32_t section_id_requested)
367 {
368
369
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
370 {
371 return false;
372 }
373
374 int32_t section_id_read;
375 29 bool catchup=false;
376 word dummy;
377 byte tempbyte;
378 char tempbuf[65536];
379
380
381
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id_requested)
382 {
383 case ID_RULES:
384 case ID_STRINGS:
385 case ID_MISC:
386 case ID_TILES:
387 case ID_COMBOS:
388 case ID_CSETS:
389 case ID_MAPS:
390 case ID_DMAPS:
391 case ID_DOORS:
392 case ID_ITEMS:
393 case ID_WEAPONS:
394 case ID_COLORS:
395 case ID_ICONS:
396 case ID_INITDATA:
397 case ID_GUYS:
398 case ID_MIDIS:
399 case ID_CHEATS:
400 29 break;
401
402 default:
403 al_trace("Bad section requested!\n");
404 return false;
405 break;
406 }
407
408 dword section_size;
409
410 //section id
411
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_mgetl(&section_id_read,f,true))
412 {
413 return false;
414 }
415
416
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 while(!pack_feof(f))
417 {
418
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 switch(section_id_read)
419 {
420 case ID_RULES:
421 case ID_STRINGS:
422 case ID_MISC:
423 case ID_TILES:
424 case ID_COMBOS:
425 case ID_CSETS:
426 case ID_MAPS:
427 case ID_DMAPS:
428 case ID_DOORS:
429 case ID_ITEMS:
430 case ID_WEAPONS:
431 case ID_COLORS:
432 case ID_ICONS:
433 case ID_INITDATA:
434 case ID_GUYS:
435 case ID_MIDIS:
436 case ID_CHEATS:
437 29 catchup=false;
438 29 break;
439
440 default:
441 5887 break;
442 }
443
444
445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5916 times.
5916 while(catchup)
446 {
447 //section id
448 section_id_read=(section_id_read<<8);
449
450 if(!p_getc(&tempbyte,f,true))
451 {
452 return false;
453 }
454
455 section_id_read+=tempbyte;
456 }
457
458
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(section_id_read==section_id_requested)
459 {
460 return true;
461 }
462 else
463 {
464 //section version info
465
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
466 {
467 return false;
468 }
469
470
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 //section size
476
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetl(&section_size,f,true))
477 {
478 return false;
479 }
480
481 //pack_fseek(f, section_size);
482
2/2
✓ Branch 0 taken 1900515 times.
✓ Branch 1 taken 5916 times.
1906431 while(section_size>65535)
483 {
484 1900515 pfread(tempbuf,65535,f,true);
485 1900515 tempbuf[65535]=0;
486 1900515 section_size-=65535;
487 }
488
489
2/2
✓ Branch 0 taken 5771 times.
✓ Branch 1 taken 145 times.
5916 if(section_size>0)
490 {
491 145 pfread(tempbuf,section_size,f,true);
492 145 tempbuf[section_size]=0;
493 145 }
494 }
495
496 //section id
497
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 if(!p_mgetl(&section_id_read,f,true))
498 {
499 29 return false;
500 }
501 }
502
503 return false;
504 29 }
505
506
507
508
509
510 29 bool valid_zqt(PACKFILE *f)
511 {
512
513 //word tiles_used;
514 //word combos_used;
515 //open the file
516 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f)
518 return false;
519
520 //for now, everything else is valid
521 29 return true;
522
523 /*int16_t version;
524 byte build;
525
526 //read the version and make sure it worked
527 if(!p_igetw(&version,f,true))
528 {
529 goto error;
530 }
531
532 //read the build and make sure it worked
533 if(!p_getc(&build,f,true))
534 goto error;
535
536 //read the tile info and make sure it worked
537 if(!p_igetw(&tiles_used,f,true))
538 {
539 goto error;
540 }
541
542 for (int32_t i=0; i<tiles_used; i++)
543 {
544 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
545 {
546 goto error;
547 }
548 }
549
550 //read the combo info and make sure it worked
551 if(!p_igetw(&combos_used,f,true))
552 {
553 goto error;
554 }
555 for (int32_t i=0; i<combos_used; i++)
556 {
557 if(!pfread(trashbuf,sizeof(newcombo),f,true))
558 {
559 goto error;
560 }
561 }
562
563 //read the palette info and make sure it worked
564 for (int32_t i=0; i<48; i++)
565 {
566 if(!pfread(trashbuf,newpdTOTAL,f,true))
567 {
568 goto error;
569 }
570 }
571 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
572 {
573 goto error;
574 }
575 for (int32_t i=0; i<MAXLEVELS; i++)
576 {
577 if(!pfread(trashbuf,PALNAMESIZE,f,true))
578 {
579 goto error;
580 }
581 }
582
583 //read the sprite info and make sure it worked
584 for (int32_t i=0; i<MAXITEMS; i++)
585 {
586 if(!pfread(trashbuf,sizeof(itemdata),f,true))
587 {
588 goto error;
589 }
590 }
591
592 for (int32_t i=0; i<MAXWPNS; i++)
593 {
594 if(!pfread(trashbuf,sizeof(wpndata),f,true))
595 {
596 goto error;
597 }
598 }
599
600 //read the triforce pieces info and make sure it worked
601 for (int32_t i=0; i<8; ++i)
602 {
603 if(!p_getc(&trashbuf,f,true))
604 {
605 goto error;
606 }
607 }
608
609
610
611 //read the game icons info and make sure it worked
612 for (int32_t i=0; i<4; ++i)
613 {
614 if(!p_igetw(&trashbuf,f,true))
615 {
616 goto error;
617 }
618 }
619
620 //read the misc colors info and map styles info and make sure it worked
621 if(!pfread(trashbuf,sizeof(zcolors),f,true))
622 {
623 goto error;
624 }
625
626 //read the template screens and make sure it worked
627 byte num_maps;
628 if(!p_getc(&num_maps,f,true))
629 {
630 goto error;
631 }
632 for (int32_t i=0; i<TEMPLATES; i++)
633 {
634 if(!pfread(trashbuf,sizeof(mapscr),f,true))
635 {
636 goto error;
637 }
638 }
639 if (num_maps>1) //dungeon templates
640 {
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f,true))
644 {
645 goto error;
646 }
647 }
648 }
649
650 //yay! it worked! close the file and say everything was ok.
651 pack_fclose(f);
652 return true;
653
654 error:
655 pack_fclose(f);
656 return false;*/
657 29 }
658
659 bool valid_zqt(const char *filename)
660 {
661 PACKFILE *f=NULL;
662 bool isvalid;
663 char deletefilename[1024];
664 deletefilename[0]=0;
665 int32_t error;
666 f=open_quest_file(&error, filename, deletefilename, true, true,false);
667
668 if(!f)
669 {
670 // setPackfilePassword(NULL);
671 return false;
672 }
673
674 isvalid=valid_zqt(f);
675
676 if(deletefilename[0])
677 {
678 delete_file(deletefilename);
679 }
680
681 // setPackfilePassword(NULL);
682 return isvalid;
683 }
684
685 128 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
686 {
687 char tmpfilename[L_tmpnam];
688 128 temp_name(tmpfilename);
689 char percent_done[30];
690 128 int32_t current_method=0;
691
692 PACKFILE *f;
693 128 const char *passwd= encrypted ? datapwd : "";
694
695 // oldquest flag is set when an unencrypted qst file is suspected.
696 128 bool oldquest = false;
697 int32_t ret;
698
699
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(show_progress)
700 {
701 box_start(1, "Loading Quest", lfont, font, true);
702 }
703
704 128 box_out("Loading Quest: ");
705 //if(strncasecmp(filename, "qst.dat", 7)!=0)
706 //int32_t qstdat_str_size = 0;
707 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
708 //{
709 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
710 // else break;
711 //}
712 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
713 128 al_trace("Trying to do strncasecmp() when loading a quest\n");
714 128 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
715 128 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
716 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
717
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
718 {
719 128 box_out(filename);
720 128 }
721 else
722 {
723 box_out("new quest"); // Or whatever
724 }
725 128 box_out("...");
726 128 box_eol();
727 128 box_eol();
728
729
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(encrypted)
730 {
731 128 box_out("Decrypting...");
732 128 box_save_x();
733 128 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
734
735
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(ret)
736 {
737
1/3
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3 switch(ret)
738 {
739 case 1:
740 box_out("error.");
741 box_eol();
742 box_end(true);
743 *open_error=qe_notfound;
744 return NULL;
745
746 case 2:
747 box_out("error.");
748 box_eol();
749 box_end(true);
750 *open_error=qe_internal;
751 return NULL;
752 // be sure not to delete tmpfilename now...
753 }
754
755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
756 {
757 3 current_method++;
758 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
759 3 box_out(percent_done);
760 3 box_load_x();
761 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
762 3 }
763
764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
765 {
766 3 current_method++;
767 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
768 3 box_out(percent_done);
769 3 box_load_x();
770 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
771 3 }
772
773
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
774 {
775 current_method++;
776 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
777 box_out(percent_done);
778 box_load_x();
779 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
780 }
781
782
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
783 {
784 current_method++;
785 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
786 box_out(percent_done);
787 box_load_x();
788 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
789 }
790
791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret)
792 {
793 oldquest = true;
794 passwd="";
795 }
796 3 }
797
798 128 box_out("okay.");
799 128 box_eol();
800 128 }
801 else
802 {
803 oldquest = true;
804 }
805
806 128 box_out("Opening...");
807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
808
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!f)
809 {
810 if((compressed==1)&&(errno==EDOM))
811 {
812 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
813 }
814
815 if(!f)
816 {
817 if(!oldquest)
818 {
819 delete_file(tmpfilename);
820 }
821 box_out("error.");
822 box_eol();
823 box_end(true);
824 *open_error=qe_invalid;
825 return NULL;
826 }
827 }
828
829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!oldquest)
830 {
831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(deletefilename)
832 128 sprintf(deletefilename, "%s", tmpfilename);
833 128 }
834
835 128 box_out("okay.");
836 128 box_eol();
837
838 128 return f;
839 128 }
840
841 29 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
842 {
843 char *filename;
844 29 PACKFILE *f=NULL;
845 29 int32_t open_error=0;
846 29 deletefilename[0]=0;
847
848 29 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
849 29 strcat(qstdat_string,"#NESQST_NEW_QST");
850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
851 {
852 29 filename=(char *)malloc(2048);
853 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
854 29 strcpy(filename, qstdat_string);
855 29 }
856 else
857 {
858 filename=Header->templatepath;
859 }
860
861 29 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
864 {
865 29 free(filename);
866 29 }
867
868
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
869 {
870 return NULL;
871 }
872
873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(validate)
874 {
875
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!valid_zqt(f))
876 {
877 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
878 pack_fclose(f);
879
880 //setPackfilePassword(NULL);
881 if(deletefilename[0])
882 {
883 delete_file(deletefilename);
884 }
885
886 return NULL;
887 }
888 29 }
889
890 29 return f;
891 29 }
892
893 29 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
894 {
895 29 combosread=false;
896 29 mapsread=false;
897 29 fixffcs=false;
898
899
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id)
900 {
901 case ID_RULES:
902 case ID_STRINGS:
903 case ID_MISC:
904 case ID_TILES:
905 case ID_COMBOS:
906 case ID_CSETS:
907 case ID_MAPS:
908 case ID_DMAPS:
909 case ID_DOORS:
910 case ID_ITEMS:
911 case ID_WEAPONS:
912 case ID_COLORS:
913 case ID_ICONS:
914 case ID_INITDATA:
915 case ID_GUYS:
916 case ID_MIDIS:
917 case ID_CHEATS:
918 case ID_ITEMDROPSETS:
919 case ID_FAVORITES:
920 29 break;
921
922 default:
923 return false;
924 break;
925 }
926
927 int32_t ret;
928 word version, build;
929 29 PACKFILE *f=NULL;
930
931 char deletefilename[1024];
932 29 deletefilename[0]=0;
933
934 //why is this here?
935 /*
936 if(colordata==NULL)
937 return false;
938 */
939
940 //setPackfilePassword(datapwd);
941 29 f=open_quest_template(Header, deletefilename, validate);
942
943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f) //no file, nothing to delete
944 {
945 // setPackfilePassword(NULL);
946 return false;
947 }
948
949 29 ret=get_version_and_build(f, &version, &build);
950
951
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if(ret||(version==0))
952 {
953 pack_fclose(f);
954
955 if(deletefilename[0])
956 {
957 delete_file(deletefilename);
958 }
959
960 // setPackfilePassword(NULL);
961 return false;
962 }
963
964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!find_section(f, section_id))
965 {
966 29 al_trace("Can't find section!\n");
967 29 pack_fclose(f);
968
969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(deletefilename[0])
970 {
971 29 delete_file(deletefilename);
972 29 }
973
974 //setPackfilePassword(NULL);
975 29 return false;
976 }
977
978 switch(section_id)
979 {
980 case ID_RULES:
981 //rules
982 ret=readrules(f, Header, true);
983 break;
984
985 case ID_STRINGS:
986 //strings
987 ret=readstrings(f, Header, true);
988 break;
989
990 case ID_MISC:
991 //misc data
992 ret=readmisc(f, Header, Misc, true);
993 break;
994
995 case ID_TILES:
996 //tiles
997 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
998 break;
999
1000 case ID_COMBOS:
1001 //combos
1002 clear_combos();
1003 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1004 combosread=true;
1005 break;
1006
1007 case ID_COMBOALIASES:
1008 //combos
1009 ret=readcomboaliases(f, Header, version, build, true);
1010 break;
1011
1012 case ID_CSETS:
1013 //color data
1014 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1015 break;
1016
1017 case ID_MAPS:
1018 //maps
1019 ret=readmaps(f, Header, true);
1020 mapsread=true;
1021 break;
1022
1023 case ID_DMAPS:
1024 //dmaps
1025 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1026 break;
1027
1028 case ID_DOORS:
1029 //door combo sets
1030 ret=readdoorcombosets(f, Header, true);
1031 break;
1032
1033 case ID_ITEMS:
1034 //items
1035 ret=readitems(f, version, build, true);
1036 break;
1037
1038 case ID_WEAPONS:
1039 //weapons
1040 ret=readweapons(f, Header, true);
1041 break;
1042
1043 case ID_COLORS:
1044 //misc. colors
1045 ret=readmisccolors(f, Header, Misc, true);
1046 break;
1047
1048 case ID_ICONS:
1049 //game icons
1050 ret=readgameicons(f, Header, Misc, true);
1051 break;
1052
1053 case ID_INITDATA:
1054 //initialization data
1055 ret=readinitdata(f, Header, true);
1056 break;
1057
1058 case ID_GUYS:
1059 //guys
1060 ret=readguys(f, Header, true);
1061 break;
1062
1063 case ID_MIDIS:
1064 //midis
1065 ret=readtunes(f, Header, tunes, true);
1066 break;
1067
1068 case ID_CHEATS:
1069 //cheat codes
1070 ret=readcheatcodes(f, Header, true);
1071 break;
1072
1073 case ID_ITEMDROPSETS:
1074 //item drop sets
1075 // Why is this one commented out?
1076 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1077 break;
1078
1079 case ID_FAVORITES:
1080 // favorite combos and aliases
1081 ret=readfavorites(f, version, build, true);
1082 break;
1083
1084 default:
1085 ret=-1;
1086 break;
1087 }
1088
1089 pack_fclose(f);
1090
1091 if(deletefilename[0])
1092 {
1093 delete_file(deletefilename);
1094 }
1095
1096 //setPackfilePassword(NULL);
1097 if(!ret)
1098 {
1099 return true;
1100 }
1101
1102 return false;
1103 29 }
1104
1105 bool init_tiles(bool validate, zquestheader *Header)
1106 {
1107 return init_section(Header, ID_TILES, NULL, NULL, validate);
1108 }
1109
1110 bool init_combos(bool validate, zquestheader *Header)
1111 {
1112 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1113 }
1114
1115 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1116 {
1117 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1118 }
1119
1120 99 void init_spritelists()
1121 {
1122
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(FFCore.quest_format[vZelda] < 0x255)
1123 {
1124 77 guys.setMax(255);
1125 77 items.setMax(255);
1126 77 Ewpns.setMax(255);
1127 77 Lwpns.setMax(255);
1128 77 Sitems.setMax(255);
1129 77 chainlinks.setMax(255);
1130 77 decorations.setMax(255);
1131 77 particles.setMax(255);
1132 77 }
1133 else
1134 {
1135 22 guys.setMax(255);
1136 22 items.setMax(255);
1137 22 Ewpns.setMax(255);
1138 22 Lwpns.setMax(255);
1139 22 Sitems.setMax(255);
1140 22 chainlinks.setMax(255);
1141 22 decorations.setMax(255);
1142 22 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1143 }
1144 99 }
1145
1146 29 bool reset_items(bool validate, zquestheader *Header)
1147 {
1148 29 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1149
1150 //Ignore this, but don't remove it
1151 /*
1152 if (ret)
1153 for(int32_t i=0; i<MAXITEMS; i++)
1154 {
1155 reset_itembuf(&itemsbuf[i], i);
1156 }
1157 */
1158
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1159
1160 29 return ret;
1161 }
1162
1163 bool reset_guys()
1164 {
1165 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1166 init_guys(V_GUYS);
1167 return true;
1168 }
1169
1170 bool reset_wpns(bool validate, zquestheader *Header)
1171 {
1172 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1173
1174 for(int32_t i=0; i<WPNCNT; i++)
1175 reset_weaponname(i);
1176
1177 return ret;
1178 }
1179
1180 bool reset_mapstyles(bool validate, miscQdata *Misc)
1181 {
1182 Misc->colors.blueframe_tile = 20044;
1183 Misc->colors.blueframe_cset = 0;
1184 Misc->colors.triforce_tile = 23461;
1185 Misc->colors.triforce_cset = 1;
1186 Misc->colors.triframe_tile = 18752;
1187 Misc->colors.triframe_cset = 1;
1188 Misc->colors.overworld_map_tile = 16990;
1189 Misc->colors.overworld_map_cset = 2;
1190 Misc->colors.HCpieces_tile = 21160;
1191 Misc->colors.HCpieces_cset = 8;
1192 Misc->colors.dungeon_map_tile = 19651;
1193 Misc->colors.dungeon_map_cset = 8;
1194 return true;
1195 }
1196
1197 bool reset_doorcombosets(bool validate, zquestheader *Header)
1198 {
1199 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1200 }
1201
1202 29 int32_t get_qst_buffers()
1203 {
1204 29 memrequested+=(sizeof(mapscr)*MAPSCRS);
1205 29 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1206 29 TheMaps.resize(MAPSCRS);
1207
1208
2/2
✓ Branch 0 taken 3944 times.
✓ Branch 1 taken 29 times.
3973 for(int32_t i(0); i<MAPSCRS; i++)
1209 3944 TheMaps[i].zero_memory();
1210
1211 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1212 29 Z_message("OK\n"); // Allocating map buffer...
1213
1214 29 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1215 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1216
1217
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1218 return 0;
1219
1220 29 Z_message("OK\n");
1221
1222 // Allocating space for all 65535 strings uses up 10.62MB...
1223 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1224 // (Shoelace's "Hero of Dreams" uses 1415.)
1225 // So let's be a bit generous and allow 4096 initially.
1226 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1227 // I tested it and it worked without flaw on 6/6/11. - L.
1228 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1229 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1230 // See https://discord.com/channels/876899628556091432/992984989073416242
1231 29 msg_strings_size = 8192;
1232 29 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1233 29 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1234
1235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 MsgStrings = new MsgStr[msg_strings_size];
1236
1237 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1238
2/2
✓ Branch 0 taken 237568 times.
✓ Branch 1 taken 29 times.
237597 for(auto q = 0; q < msg_strings_size; ++q)
1239 {
1240 237568 MsgStrings[q].clear();
1241 237568 }
1242 29 Z_message("OK\n"); // Allocating string buffer...
1243
1244 29 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1245 29 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1246
1247
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1248 return 0;
1249
1250 29 Z_message("OK\n"); // Allocating door combo buffer...
1251
1252 29 memrequested+=(sizeof(dmap)*MAXDMAPS);
1253 29 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1254
1255
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1256 return 0;
1257
1258 29 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1259 29 Z_message("OK\n"); // Allocating dmap buffer...
1260
1261 29 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1262 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1263
1264
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1265 return 0;
1266
1267 29 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1268 29 Z_message("OK\n"); // Allocating combo buffer...
1269
1270 29 memrequested+=(psTOTAL255);
1271 29 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1272
1273
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1274 return 0;
1275
1276 29 Z_message("OK\n"); // Allocating color data buffer...
1277
1278 29 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1279 29 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1280
1281 29 free_newtilebuf();
1282
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1283 return 0;
1284
1285 29 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1286 //Z_message("Performed memset on tiles\n");
1287 29 clear_tiles(newtilebuf);
1288 //Z_message("Performed clear_tiles()\n");
1289 29 Z_message("OK\n"); // Allocating tile buffer...
1290
1291
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(is_zquest())
1292 {
1293 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1294 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1295
1296 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1297 return 0;
1298
1299 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1300 clear_tiles(grabtilebuf);
1301 Z_message("OK\n"); // Allocating tile grab buffer...
1302 }
1303
1304 29 memrequested+=(100000);
1305 29 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1306
1307
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((trashbuf=(byte*)malloc(100000))==NULL)
1308 return 0;
1309
1310 29 Z_message("OK\n"); // Allocating trash buffer...
1311
1312 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1313 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1314 // fixed by ensuring there's actually itemdata there.
1315 // If you change this, be sure to update del_qst_buffers, too.
1316
1317 29 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1318 29 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1319
1320
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1321 return 0;
1322
1323 29 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1324 29 itemsbuf++;
1325 29 Z_message("OK\n"); // Allocating item buffer...
1326
1327 29 memrequested+=(sizeof(wpndata)*MAXWPNS);
1328 29 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1329
1330
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1331 return 0;
1332
1333 29 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1334 29 Z_message("OK\n"); // Allocating weapon buffer...
1335
1336 29 memrequested+=(sizeof(guydata)*MAXGUYS);
1337 29 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1340 return 0;
1341
1342 29 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1343 29 Z_message("OK\n"); // Allocating guy buffer...
1344
1345 29 memrequested+=(sizeof(comboclass)*cMAX);
1346 29 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1347
1348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1349 return 0;
1350
1351 29 Z_message("OK\n"); // Allocating combo class buffer...
1352
1353 29 return 1;
1354 29 }
1355
1356
1357 29 void free_newtilebuf()
1358 {
1359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(newtilebuf)
1360 {
1361 for(int32_t i=0; i<NEWMAXTILES; i++)
1362 if(newtilebuf[i].data)
1363 free(newtilebuf[i].data);
1364
1365 free(newtilebuf);
1366 newtilebuf = 0;
1367 }
1368 29 }
1369
1370 void free_grabtilebuf()
1371 {
1372 if(is_zquest())
1373 {
1374 if(grabtilebuf)
1375 {
1376 for(int32_t i=0; i<NEWMAXTILES; i++)
1377 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1378
1379 free(grabtilebuf);
1380 grabtilebuf = 0;
1381 }
1382 }
1383 }
1384
1385 void del_qst_buffers()
1386 {
1387 al_trace("Cleaning maps. \n");
1388
1389 if(ZCMaps) free(ZCMaps);
1390
1391 if(MsgStrings) delete[] MsgStrings;
1392
1393 if(DoorComboSets) free(DoorComboSets);
1394
1395 if(DMaps) free(DMaps);
1396
1397 if(combobuf) free(combobuf);
1398
1399 if(colordata) free(colordata);
1400
1401 al_trace("Cleaning tile buffers. \n");
1402 free_newtilebuf();
1403 free_grabtilebuf();
1404
1405 al_trace("Cleaning misc. \n");
1406
1407 if(trashbuf) free(trashbuf);
1408
1409 // See get_qst_buffers
1410 if(itemsbuf)
1411 {
1412 itemsbuf--;
1413 free(itemsbuf);
1414 }
1415
1416 if(wpnsbuf) free(wpnsbuf);
1417
1418 if(guysbuf) free(guysbuf);
1419
1420 if(combo_class_buf) free(combo_class_buf);
1421 }
1422
1423 bool init_palnames()
1424 {
1425 // if(palnames==NULL)
1426 // return false;
1427
1428 for(int32_t x=0; x<MAXLEVELS; x++)
1429 {
1430 switch(x)
1431 {
1432 case 0:
1433 sprintf(palnames[x],"Overworld");
1434 break;
1435
1436 case 10:
1437 sprintf(palnames[x],"Caves");
1438 break;
1439
1440 case 11:
1441 sprintf(palnames[x],"Passageways");
1442 break;
1443
1444 default:
1445 sprintf(palnames[x],"%c",0);
1446 break;
1447 }
1448 }
1449
1450 return true;
1451 }
1452
1453 18953 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1454 {
1455 void *p;
1456
1457
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 p = _AL_MALLOC(MAX(size, alloc_size));
1458
1459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18953 times.
18953 if(!p)
1460 {
1461 return NULL;
1462 }
1463
1464
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!pfread(p,size,f,keepdata))
1465 {
1466 _AL_FREE(p);
1467 return NULL;
1468 }
1469
1470
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(pack_ferror(f))
1471 {
1472 _AL_FREE(p);
1473 return NULL;
1474 }
1475
1476 18953 return p;
1477 18953 }
1478
1479 /* read_midi:
1480 * Reads MIDI data from a datafile (this is not the same thing as the
1481 * standard midi file format).
1482 */
1483
1484 1629 static MIDI *read_midi(PACKFILE *f, bool)
1485 {
1486 MIDI *m;
1487 int32_t c;
1488 1629 int16_t divisions=0;
1489 1629 int32_t len=0;
1490
1491 1629 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1492
1493
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!m)
1494 {
1495 return NULL;
1496 }
1497
1498
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1499 {
1500 52128 m->track[c].len = 0;
1501 52128 m->track[c].data = NULL;
1502 52128 }
1503
1504 1629 p_mgetw(&divisions,f,true);
1505 1629 m->divisions=divisions;
1506
1507
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1508 {
1509 52128 p_mgetl(&len,f,true);
1510 52128 m->track[c].len=len;
1511
1512
2/2
✓ Branch 0 taken 33175 times.
✓ Branch 1 taken 18953 times.
52128 if(m->track[c].len > 0)
1513 {
1514 18953 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1515
1516
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!m->track[c].data)
1517 {
1518 destroy_midi(m);
1519 return NULL;
1520 }
1521 18953 }
1522 52128 }
1523
1524 LOCK_DATA(m, sizeof(MIDI));
1525
1526
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1527 {
1528
2/2
✓ Branch 0 taken 18953 times.
✓ Branch 1 taken 33175 times.
52128 if(m->track[c].data)
1529 {
1530 LOCK_DATA(m->track[c].data, m->track[c].len);
1531 18953 }
1532 52128 }
1533
1534 1629 return m;
1535 1629 }
1536
1537 void clear_combo(int32_t i)
1538 {
1539 combobuf[i].clear();
1540 }
1541
1542 void clear_combos()
1543 {
1544 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1545 clear_combo(tmpcounter);
1546 }
1547
1548 void pack_combos()
1549 {
1550 int32_t di = 0;
1551
1552 for(int32_t si=0; si<1024; si+=2)
1553 combobuf[di++] = combobuf[si];
1554
1555 for(; di<1024; di++)
1556 clear_combo(di);
1557 }
1558
1559 99 void reset_tunes(zctune *tune)
1560 {
1561
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1562 {
1563 24948 tune[i].reset();
1564 24948 }
1565 99 }
1566
1567
1568 /*void reset_midi(zcmidi_ *m)
1569 {
1570 m->title[0]=0;
1571 m->loop=1;
1572 m->volume=144;
1573 m->start=0;
1574 m->loop_start=-1;
1575 m->loop_end=-1;
1576 if(m->midi)
1577 {
1578 destroy_midi(m->midi);
1579 }
1580 m->midi=NULL;
1581 }
1582
1583
1584 void reset_midis(zcmidi_ *m)
1585 {
1586 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1587 {
1588 reset_midi(m+i);
1589 }
1590 }
1591 */
1592
1593 void reset_scr(int32_t scr)
1594 {
1595 /*
1596 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1597 for(unsigned i=0; i<sizeof(mapscr); i++)
1598 *(di++) = 0;
1599 TheMaps[scr].valid=mVERSION;
1600 */
1601
1602 TheMaps[scr].zero_memory();
1603 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1604
1605 for(int32_t i=0; i<6; i++)
1606 {
1607 //these will be uncommented later
1608 //TheMaps[scr].layerxsize[i]=16;
1609 //TheMaps[scr].layerysize[i]=11;
1610 TheMaps[scr].layeropacity[i]=255;
1611 }
1612
1613 TheMaps[scr].valid=mVERSION;
1614
1615 }
1616
1617 /* For reference:
1618
1619 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1620 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1621 */
1622
1623 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1624 {
1625 for(int32_t i=0; i<9; i++)
1626 {
1627 for(int32_t j=0; j<6; j++)
1628 {
1629 if(j<4)
1630 {
1631 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1632 {
1633 return false;
1634 }
1635
1636 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1637 {
1638 return false;
1639 }
1640
1641 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1642 {
1643 return false;
1644 }
1645
1646 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1647 {
1648 return false;
1649 }
1650 }
1651
1652 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1653 {
1654 return false;
1655 }
1656
1657 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1663 {
1664 return false;
1665 }
1666
1667 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1668 {
1669 return false;
1670 }
1671 }
1672
1673 if(i<2)
1674 {
1675 if(a.flags[i]!=b.flags[i])
1676 {
1677 return false;
1678 }
1679
1680 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1681 {
1682 return false;
1683 }
1684
1685 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1686 {
1687 return false;
1688 }
1689
1690 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1691 {
1692 return false;
1693 }
1694
1695 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1696 {
1697 return false;
1698 }
1699 }
1700
1701 if(i<3)
1702 {
1703 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1704 {
1705 return false;
1706 }
1707
1708 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1709 {
1710 return false;
1711 }
1712
1713 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1714 {
1715 return false;
1716 }
1717
1718 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1719 {
1720 return false;
1721 }
1722 }
1723
1724 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1725 {
1726 return false;
1727 }
1728
1729 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1730 {
1731 return false;
1732 }
1733 }
1734
1735 return true;
1736 }
1737
1738 int32_t doortranslations_u[9][4]=
1739 {
1740 {37,38,53,54},
1741 {37,38,39,40},
1742 {37,38,55,56},
1743 {37,38,39,40},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {37,38,53,54},
1747 {7,8,23,24},
1748 {7,8,41,42}
1749 };
1750
1751 int32_t doortranslations_d[9][4]=
1752 {
1753 {117,118,133,134},
1754 {135,136,133,134},
1755 {119,120,133,134},
1756 {135,136,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {117,118,133,134},
1760 {151,152,167,168},
1761 {137,138,167,168},
1762 };
1763
1764 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1765 int32_t doortranslations_l[9][6]=
1766 {
1767 {66,67,82,83,98,99},
1768 {66,68,82,84,98,100},
1769 {66,69,82,85,98,101},
1770 {66,68,82,84,98,100},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {66,67,82,83,98,99},
1774 {64,65,80,81,96,97},
1775 {64,65,80,114,96,97},
1776 };
1777
1778 int32_t doortranslations_r[9][6]=
1779 {
1780
1781 {76,77,92,93,108,109},
1782 {75,77,91,93,107,109},
1783 {74,77,90,93,106,109},
1784 {75,77,91,93,107,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {76,77,92,93,108,109},
1788 {78,79,94,95,110,111},
1789 {78,79,125,95,110,111},
1790 };
1791
1792 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1793 {
1794 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1795 }
1796
1797 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 //these are here to bypass compiler warnings about unused arguments
1800 map=map;
1801 scr=scr;
1802 pos=pos;
1803
1804 //what does this function do?
1805 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1806 return 2;
1807 }
1808
1809 int32_t MakeDoors(int32_t map, int32_t scr)
1810 {
1811 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1812 {
1813 return 0;
1814 }
1815
1816 DoorComboSet tempdcs;
1817 memset(&tempdcs, 0, sizeof(DoorComboSet));
1818
1819 //up
1820 for(int32_t i=0; i<9; i++)
1821 {
1822 for(int32_t j=0; j<4; j++)
1823 {
1824 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1825 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1826 }
1827 }
1828
1829 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1830 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1831 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1832 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1833 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1834 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1835
1836 //down
1837 for(int32_t i=0; i<9; i++)
1838 {
1839 for(int32_t j=0; j<4; j++)
1840 {
1841 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1842 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1843 }
1844 }
1845
1846 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1847
1848 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1849 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1850 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1851 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1852 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1853
1854 //left
1855 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1856 for(int32_t i=0; i<9; i++)
1857 {
1858 for(int32_t j=0; j<6; j++)
1859 {
1860 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1861 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1862 }
1863 }
1864
1865 for(int32_t j=0; j>6; j++)
1866 {
1867 if((j!=2)&&(j!=3))
1868 {
1869 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1870 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1871 }
1872 }
1873
1874 tempdcs.bombdoorcombo_l[0]=0;
1875 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1876 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1877 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1878 tempdcs.bombdoorcombo_l[2]=0;
1879 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1880 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1881 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1882
1883 //right
1884 for(int32_t i=0; i<9; i++)
1885 {
1886 for(int32_t j=0; j<6; j++)
1887 {
1888 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1889 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1890 }
1891 }
1892
1893 for(int32_t j=0; j>6; j++)
1894 {
1895 if((j!=2)&&(j!=3))
1896 {
1897 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1898 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1899 }
1900 }
1901
1902 tempdcs.bombdoorcombo_r[0]=0;
1903 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1904 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1905 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1906 tempdcs.bombdoorcombo_r[2]=0;
1907 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1908 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1909 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1910
1911 int32_t k;
1912
1913 for(k=0; k<door_combo_set_count; k++)
1914 {
1915 if(DoorComboSets[k]==tempdcs)
1916 {
1917 break;
1918 }
1919 }
1920
1921 if(k==door_combo_set_count)
1922 {
1923 DoorComboSets[k]=tempdcs;
1924 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1925 ++door_combo_set_count;
1926 }
1927
1928 return k;
1929 /*
1930 doorcombo_u[9][4];
1931 doorcset_u[9][4];
1932 doorcombo_d[9][4];
1933 doorcset_d[9][4];
1934 doorcombo_l[9][6];
1935 doorcset_l[9][6];
1936 doorcombo_r[9][6];
1937 doorcset_r[9][6];
1938 bombdoorcombo_u[2];
1939 bombdoorcset_u[2];
1940 bombdoorcombo_d[2];
1941 bombdoorcset_d[2];
1942 bombdoorcombo_l[3];
1943 bombdoorcset_l[3];
1944 bombdoorcombo_r[3];
1945 bombdoorcset_r[3];
1946 walkthroughcombo[4];
1947 walkthroughcset[4];
1948 */
1949 }
1950
1951 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1952 {
1953 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1954 }
1955
1956 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1957 {
1958
1959 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1960 }
1961
1962 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1963 {
1964 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1965 }
1966
1967
1968 3 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1969 {
1970 char temp_pwd[30];
1971 3 memset(temp_pwd,0,30);
1972
1973
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(pwdkey!=0)
1974 {
1975 3 memcpy(temp_pwd,encrypted_pwd,30);
1976 3 temp_pwd[29]=0;
1977
1978
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 3 times.
93 for(int32_t i=0; i<30; i++)
1979 {
1980 90 temp_pwd[i] -= pwdkey;
1981 90 int32_t t=pwdkey>>15;
1982 90 pwdkey = (pwdkey<<1)+t;
1983 90 }
1984 3 }
1985
1986 3 memcpy(pwd,temp_pwd,30);
1987 3 }
1988
1989
1990 79 bool devpwd()
1991 {
1992 #ifdef _DEBUG
1993 return true;
1994 #endif
1995 79 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
1996 }
1997 bool check_questpwd(zquestheader *Header, char *pwd)
1998 {
1999 #if DEVLEVEL > 3
2000 return true;
2001 #endif
2002
2003 if (devpwd()) return true;
2004 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2005 cvs_MD5Context ctx;
2006 uint8_t md5sum[16];
2007
2008 cvs_MD5Init(&ctx);
2009 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2010 cvs_MD5Final(md5sum, &ctx);
2011
2012 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2013 }
2014
2015 94 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2016 {
2017 94 zprint2("\n");
2018 94 zprint2("[ZQUEST CREATOR METADATA]\n");
2019
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(qst_num < moduledata.max_quest_files)
2020 zprint2("Loading module quest %d\n", qst_num+1);
2021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(path) zprint2("Loading '%s'\n", path);
2022
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( tempheader.new_version_id_main > 0 )
2023 {
2024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(tempheader.new_version_id_fourth > 0)
2025 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2026 tempheader.new_version_id_main,tempheader.new_version_id_second,
2027 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2028 94 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2029 94 tempheader.new_version_id_main,tempheader.new_version_id_second,
2030 94 tempheader.new_version_id_third);
2031 94 }
2032 else
2033 {
2034 switch ( tempheader.zelda_version )
2035 {
2036 case 0x255:
2037 {
2038 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2039 break;
2040 }
2041 case 0x254:
2042 {
2043 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2044 break;
2045 }
2046 case 0x250:
2047 {
2048 switch(tempheader.build)
2049 {
2050 case 19:
2051 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2052 case 20:
2053 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2054 case 21:
2055 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2056 case 22:
2057 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2058 case 23:
2059 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2060 case 24:
2061 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2062 case 25:
2063 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2064 case 26:
2065 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2066 case 27:
2067 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2068 case 28:
2069 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2070 case 29:
2071 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2072 case 30:
2073 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2074 case 31:
2075 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2076 case 32:
2077 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2078 case 33:
2079 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2080 default:
2081 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2082
2083 }
2084 break;
2085 }
2086
2087 case 0x211:
2088 {
2089 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2090 }
2091 case 0x210:
2092 {
2093 zprint2("Last saved in ZQuest Version: 2.10.x");
2094 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2095 break;
2096 }
2097 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2098 case 0x193:
2099 {
2100 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2101 }
2102 case 0x192:
2103 {
2104 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2105 }
2106 case 0x190:
2107 {
2108 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2109 }
2110 case 0x184:
2111 {
2112 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2113 }
2114 case 0x183:
2115 {
2116 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2117 }
2118 case 0x180:
2119 {
2120 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2121 }
2122 default:
2123 {
2124 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2125 }
2126 */
2127 }
2128 }
2129
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
94 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2130 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2131 77 else zprint2("\n");
2132
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2133
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2134
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2135
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2137
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2138 94 zprint2("\n");
2139 94 }
2140
2141 128 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2142 {
2143 int32_t dummy;
2144 zquestheader tempheader;
2145 char dummybuf[80];
2146 byte temp_map_count;
2147 byte temp_midi_flags[MIDIFLAGS_SIZE];
2148 word version;
2149 char temp_pwd[30], temp_pwd2[30];
2150 int16_t temp_pwdkey;
2151 cvs_MD5Context ctx;
2152 128 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2153 128 memset(&tempheader, 0, sizeof(tempheader));
2154 128 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2155
2156
2157
2158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2159 {
2160 Z_message("Unable to read header string\n");
2161 return qe_invalid;
2162 }
2163
2164 // check header
2165
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2166 {
2167 if(strcmp(tempheader.id_str,QH_IDSTR))
2168 {
2169 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2170 return qe_invalid;
2171 }
2172 }
2173
2174 128 int32_t templatepath_len=0;
2175
2176 128 tempheader.external_zinfo = false;
2177 128 read_zinfo = false;
2178
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2179 {
2180 byte padding;
2181
2182 if(!p_getc(&padding,f,true))
2183 {
2184 return qe_invalid;
2185 }
2186
2187 if(!p_igetw(&tempheader.zelda_version,f,true))
2188 {
2189 return qe_invalid;
2190 }
2191
2192 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2193
2194 if(tempheader.zelda_version > ZELDA_VERSION)
2195 {
2196 return qe_version;
2197 }
2198
2199 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2200
2201 if(strcmp(tempheader.id_str,QH_IDSTR))
2202 {
2203 return qe_invalid;
2204 }
2205
2206 if(bad_version(tempheader.zelda_version))
2207 {
2208 return qe_obsolete;
2209 }
2210
2211 if(!p_igetw(&tempheader.internal,f,true))
2212 {
2213 return qe_invalid;
2214 }
2215
2216 if(!p_getc(&tempheader.quest_number,f,true))
2217 {
2218 return qe_invalid;
2219 }
2220
2221 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2222
2223 if(!pfread(&quest_rules[0],2,f,true))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 if(!p_getc(&temp_map_count,f,true))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 FFCore.quest_format[qMapCount] = temp_map_count;
2234
2235 if(!p_getc(&tempheader.old_str_count,f,true))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2241 {
2242 return qe_invalid;
2243 }
2244
2245 if(!pfread(temp_midi_flags,4,f,true))
2246 {
2247 return qe_invalid;
2248 }
2249
2250 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2251 {
2252 return qe_invalid;
2253 }
2254
2255 if(!pfread(dummybuf,14,f,true))
2256 {
2257 return qe_invalid;
2258 }
2259
2260 if(!pfread(&quest_rules[2],2,f,true))
2261 {
2262 return qe_invalid;
2263 }
2264
2265 if(!p_getc(&dummybuf,f,true))
2266 {
2267 return qe_invalid;
2268 }
2269
2270 if(!pfread(tempheader.version,9,f,true))
2271 {
2272 return qe_invalid;
2273 }
2274
2275 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2276 {
2277 return qe_invalid;
2278 }
2279 // These fields are expected to end in null bytes!
2280 tempheader.title[sizeof(tempheader.title)-1] = 0;
2281
2282 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2283 {
2284 return qe_invalid;
2285 }
2286 tempheader.author[sizeof(tempheader.author)-1] = 0;
2287
2288 if(!p_getc(&padding,f,true))
2289 {
2290 return qe_invalid;
2291 }
2292
2293 if(!p_igetw(&temp_pwdkey,f,true))
2294 {
2295 return qe_invalid;
2296 }
2297
2298 if(!pfread(temp_pwd,30,f,true))
2299 {
2300 return qe_invalid;
2301 }
2302
2303 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2304 cvs_MD5Init(&ctx);
2305 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2306 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2307
2308 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2309 {
2310 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2311 // Not anymore...
2312 memset(tempheader.minver,0,17);
2313 tempheader.build=0;
2314 tempheader.use_keyfile=0;
2315 memset(tempheader.old_foo, 0, 9);
2316 }
2317 else
2318 {
2319 if(!pfread(tempheader.minver,9,f,true))
2320 {
2321 return qe_invalid;
2322 }
2323
2324 if(!p_getc(&tempheader.build,f,true))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 FFCore.quest_format[vBuild] = tempheader.build;
2330
2331 if(!p_getc(&tempheader.use_keyfile,f,true))
2332 {
2333 return qe_invalid;
2334 }
2335
2336 if(!pfread(dummybuf,9,f,true))
2337 {
2338 return qe_invalid;
2339 }
2340 } // starting at minver
2341
2342 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2343 {
2344 memset(&quest_rules[4],0,16); // word rules3..rules10
2345 }
2346 else
2347 {
2348 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2349 {
2350 return qe_invalid; // starting at rules3
2351 }
2352
2353 if(tempheader.zelda_version <= 0x190)
2354 {
2355 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2356 }
2357 }
2358
2359 if((tempheader.zelda_version < 0x192)||
2360 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2361 {
2362 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2363 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2364 }
2365
2366 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2367 {
2368 byte *mf=temp_midi_flags;
2369
2370 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2371 {
2372 mf=(byte*)dummybuf;
2373 }
2374
2375 if(!pfread(mf,32,f,true)) // read new header additions
2376 {
2377 return qe_invalid; // starting at foo2
2378 }
2379
2380 if(!pfread(dummybuf,18,f,true)) // read new header additions
2381 {
2382 return qe_invalid; // starting at foo2
2383 }
2384 }
2385
2386 if((tempheader.zelda_version < 0x192)||
2387 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2388 {
2389 memset(tempheader.templatepath,0,2048);
2390 }
2391 else
2392 {
2393 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2394 {
2395 return qe_invalid;
2396 }
2397 }
2398
2399 if((tempheader.zelda_version < 0x192)||
2400 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2401 {
2402 tempheader.use_keyfile=0;
2403 }
2404 }
2405 else
2406 {
2407 //section id
2408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_mgetl(&dummy,f,true))
2409 {
2410 return qe_invalid;
2411 }
2412
2413 //section version info
2414
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&version,f,true))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 128 FFCore.quest_format[vHeader] = version;
2420
2421
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&dummy,f,true))
2422 {
2423 return qe_invalid;
2424 }
2425
2426 //section size
2427
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&dummy,f,true))
2428 {
2429 return qe_invalid;
2430 }
2431
2432 //finally... section data
2433
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.zelda_version,f,true))
2434 {
2435 return qe_invalid;
2436 }
2437
2438 128 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2439
2440 //do some quick checking...
2441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(tempheader.zelda_version > ZELDA_VERSION)
2442 {
2443 return qe_version;
2444 }
2445
2446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2447 {
2448 return qe_invalid;
2449 }
2450
2451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(bad_version(tempheader.zelda_version))
2452 {
2453 return qe_obsolete;
2454 }
2455
2456
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.build,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 128 FFCore.quest_format[vBuild] = tempheader.build;
2462
2463
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 125 times.
128 if(version<3)
2464 {
2465
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!pfread(temp_pwd,30,f,true))
2466 {
2467 return qe_invalid;
2468 }
2469
2470
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_pwdkey,f,true))
2471 {
2472 return qe_invalid;
2473 }
2474
2475 3 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2476 3 cvs_MD5Init(&ctx);
2477 3 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2478 3 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2479 3 }
2480 else
2481 {
2482
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2483 {
2484 return qe_invalid;
2485 }
2486 }
2487
2488
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.internal,f,true))
2489 {
2490 return qe_invalid;
2491 }
2492
2493
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.quest_number,f,true))
2494 {
2495 return qe_invalid;
2496 }
2497
2498 128 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2499
2500 128 size_t versz = version < 8 ? 9 : 16;
2501
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.version,versz,f,true))
2502 {
2503 return qe_invalid;
2504 }
2505
2506 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2507 //needs to be copied as char[9] or stored as a s.str
2508
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.minver,versz,f,true))
2509 {
2510 return qe_invalid;
2511 }
2512
2513 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2514
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2515 {
2516 return qe_invalid;
2517 }
2518 128 tempheader.title[sizeof(tempheader.title)-1] = 0;
2519
2520
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2521 {
2522 return qe_invalid;
2523 }
2524 128 tempheader.author[sizeof(tempheader.author)-1] = 0;
2525
2526
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.use_keyfile,f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531 /*
2532 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2533 {
2534 return qe_invalid;
2535 }
2536 */
2537
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2538 {
2539 return qe_invalid;
2540 }
2541
2542
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(&dummybuf,4,f,true))
2543 {
2544 return qe_invalid;
2545 }
2546
2547
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2548 {
2549 return qe_invalid;
2550 }
2551
2552
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(dummybuf,14,f,true))
2553 {
2554 return qe_invalid;
2555 }
2556
2557 128 templatepath_len=sizeof(tempheader.templatepath);
2558
2559
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(version==1)
2560 {
2561 3 templatepath_len=280;
2562 3 }
2563
2564
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2565 {
2566 return qe_invalid;
2567 }
2568
2569
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_map_count,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
2574
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version>=4)
2575 {
2576
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2577 {
2578 return qe_invalid;
2579 }
2580
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2581 {
2582 return qe_invalid;
2583 }
2584
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2585 {
2586 return qe_invalid;
2587 }
2588
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2589 {
2590 return qe_invalid;
2591 }
2592
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2593 {
2594 return qe_invalid;
2595 }
2596
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2597 {
2598 return qe_invalid;
2599 }
2600
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2601 {
2602 return qe_invalid;
2603 }
2604
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2605 {
2606 return qe_invalid;
2607 }
2608
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2609 {
2610 return qe_invalid;
2611 }
2612
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2613 {
2614 return qe_invalid;
2615 }
2616
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2617 {
2618 return qe_invalid;
2619 }
2620
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2621 {
2622 return qe_invalid;
2623 }
2624
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
2629
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_devsig,256,f,true))
2630 {
2631 return qe_invalid;
2632 }
2633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2634 strcpy(tempheader.new_version_devsig, "EmilyV99");
2635
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilername,256,f,true))
2636 {
2637 return qe_invalid;
2638 }
2639
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2640 {
2641 return qe_invalid;
2642 }
2643
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.product_name,1024,f,true))
2644 {
2645 return qe_invalid;
2646 }
2647
2648
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.compilerid,f,true))
2649 {
2650 return qe_invalid;
2651 }
2652
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2653 {
2654 return qe_invalid;
2655 }
2656
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2657 {
2658 return qe_invalid;
2659 }
2660
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2661 {
2662 return qe_invalid;
2663 }
2664
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2665 {
2666 return qe_invalid;
2667 }
2668
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.developerid,f,true))
2669 {
2670 return qe_invalid;
2671 }
2672
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2673 {
2674 return qe_invalid;
2675 }
2676
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_datestamp,256,f,true))
2677 {
2678 return qe_invalid;
2679 }
2680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!pfread(tempheader.build_timestamp,256,f,true))
2681 {
2682 return qe_invalid;
2683 }
2684 51 }
2685 else // <4
2686 {
2687 77 tempheader.new_version_id_main = 0;
2688 77 tempheader.new_version_id_second = 0;
2689 77 tempheader.new_version_id_third = 0;
2690 77 tempheader.new_version_id_fourth = 0;
2691 77 tempheader.new_version_id_alpha = 0;
2692 77 tempheader.new_version_id_beta = 0;
2693 77 tempheader.new_version_id_gamma = 0;
2694 77 tempheader.new_version_id_release = 0;
2695 77 tempheader.new_version_id_date_year = 0;
2696 77 tempheader.new_version_id_date_month = 0;
2697 77 tempheader.new_version_id_date_day = 0;
2698 77 tempheader.new_version_id_date_hour = 0;
2699 77 tempheader.new_version_id_date_minute = 0;
2700
2701 77 memset(tempheader.new_version_devsig, 0, 256);
2702 77 memset(tempheader.new_version_compilername, 0, 256);
2703 77 memset(tempheader.new_version_compilerversion, 0, 256);
2704 77 memset(tempheader.product_name, 0, 1024);
2705 77 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2706
2707 77 tempheader.compilerid = 0;
2708 77 tempheader.compilerversionnumber_first = 0;
2709 77 tempheader.compilerversionnumber_second = 0;
2710 77 tempheader.compilerversionnumber_third = 0;
2711 77 tempheader.compilerversionnumber_fourth = 0;
2712 77 tempheader.developerid = 0;
2713
2714 77 memset(tempheader.made_in_module_name, 0, 1024);
2715 77 memset(tempheader.build_datestamp, 0, 256);
2716 77 memset(tempheader.build_timestamp, 0, 256);
2717 }
2718
2719
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if ( version >= 5 )
2720 {
2721
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_timezone,6,f,true))
2722 {
2723 return qe_invalid;
2724 }
2725 51 }
2726 else // < 5
2727 {
2728 77 memset(tempheader.build_timezone, 0, 6);
2729 }
2730
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
128 if ( version >= 6 )
2731 {
2732 byte b;
2733
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&b,f,true))
2734 {
2735 return qe_invalid;
2736 }
2737 51 tempheader.external_zinfo = b?true:false;
2738 51 read_zinfo = true;
2739 51 }
2740
2741
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version >= 7)
2742 {
2743
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2744 {
2745 return qe_invalid;
2746 }
2747 51 }
2748 else
2749 {
2750 77 tempheader.new_version_is_nightly = false;
2751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(tempheader.zelda_version < 0x255)
2752 {
2753
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
77 switch(tempheader.zelda_version)
2754 {
2755 case 0x254:
2756 tempheader.new_version_id_main = 2;
2757 tempheader.new_version_id_second = 54;
2758 break;
2759 case 0x250:
2760
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
74 switch(tempheader.build)
2761 {
2762 case 19:
2763 tempheader.new_version_id_main = 2;
2764 tempheader.new_version_id_second = 50;
2765 tempheader.new_version_id_gamma = 1;
2766 break;
2767 case 20:
2768 tempheader.new_version_id_main = 2;
2769 tempheader.new_version_id_second = 50;
2770 tempheader.new_version_id_gamma = 2;
2771 break;
2772 case 21:
2773 tempheader.new_version_id_main = 2;
2774 tempheader.new_version_id_second = 50;
2775 tempheader.new_version_id_gamma = 3;
2776 break;
2777 case 22:
2778 tempheader.new_version_id_main = 2;
2779 tempheader.new_version_id_second = 50;
2780 tempheader.new_version_id_gamma = 4;
2781 break;
2782 case 23:
2783 tempheader.new_version_id_main = 2;
2784 tempheader.new_version_id_second = 50;
2785 tempheader.new_version_id_gamma = 5;
2786 break;
2787 case 24:
2788 22 tempheader.new_version_id_main = 2;
2789 22 tempheader.new_version_id_second = 50;
2790 22 tempheader.new_version_id_release = -1;
2791 22 break;
2792 case 25:
2793 tempheader.new_version_id_main = 2;
2794 tempheader.new_version_id_second = 50;
2795 tempheader.new_version_id_third = 1;
2796 tempheader.new_version_id_gamma = 1;
2797 break;
2798 case 26:
2799 tempheader.new_version_id_main = 2;
2800 tempheader.new_version_id_second = 50;
2801 tempheader.new_version_id_third = 1;
2802 tempheader.new_version_id_gamma = 2;
2803 break;
2804 case 27:
2805 tempheader.new_version_id_main = 2;
2806 tempheader.new_version_id_second = 50;
2807 tempheader.new_version_id_third = 1;
2808 tempheader.new_version_id_gamma = 3;
2809 break;
2810 case 28:
2811 5 tempheader.new_version_id_main = 2;
2812 5 tempheader.new_version_id_second = 50;
2813 5 tempheader.new_version_id_third = 1;
2814 5 tempheader.new_version_id_release = -1;
2815 5 break;
2816 case 29:
2817 24 tempheader.new_version_id_main = 2;
2818 24 tempheader.new_version_id_second = 50;
2819 24 tempheader.new_version_id_third = 2;
2820 24 tempheader.new_version_id_release = -1;
2821 24 break;
2822 case 30:
2823 tempheader.new_version_id_main = 2;
2824 tempheader.new_version_id_second = 50;
2825 tempheader.new_version_id_third = 3;
2826 tempheader.new_version_id_gamma = 1;
2827 break;
2828 case 31:
2829 15 tempheader.new_version_id_main = 2;
2830 15 tempheader.new_version_id_second = 53;
2831 15 tempheader.new_version_id_gamma = -1;
2832 15 break;
2833 case 32:
2834 8 tempheader.new_version_id_main = 2;
2835 8 tempheader.new_version_id_second = 53;
2836 8 tempheader.new_version_id_release = -1;
2837 8 break;
2838 case 33:
2839 tempheader.new_version_id_main = 2;
2840 tempheader.new_version_id_second = 53;
2841 tempheader.new_version_id_third = 1;
2842 break;
2843 }
2844 74 break;
2845
2846 case 0x211:
2847 tempheader.new_version_id_main = 2;
2848 tempheader.new_version_id_second = 11;
2849 tempheader.new_version_id_beta = tempheader.build;
2850 break;
2851 case 0x210:
2852 3 tempheader.new_version_id_main = 2;
2853 3 tempheader.new_version_id_second = 10;
2854 3 tempheader.new_version_id_beta = tempheader.build;
2855 3 break;
2856 }
2857 77 }
2858 }
2859
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if(printmetadata || __isZQuest)
2860 {
2861 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2862 }
2863 }
2864
2865 //{ Version Warning
2866 128 int32_t vercmp = tempheader.compareVer();
2867 128 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2868 128 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2869
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
179 if(vercmp > 0 || (!vercmp &&
2870
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 (astatecmp > 0 || (!astatecmp &&
2871 51 avercmp > 0))))
2872 {
2873 bool r = true;
2874 if(loadquest_report)
2875 {
2876 enter_sys_pal();
2877 AlertDialog("Quest saved in newer version",
2878 "This quest was last saved in a newer version of ZQuest."
2879 " Attempting to load this quest may not work correctly; to"
2880 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2881 "\n\nWould you like to continue loading anyway? (Not recommended)",
2882 [&](bool ret,bool)
2883 {
2884 r = ret;
2885 }).show();
2886 exit_sys_pal();
2887 }
2888 if(!r)
2889 return qe_silenterr;
2890 }
2891
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 else if(tempheader.compareDate() > 0)
2892 {
2893 bool r = true;
2894 if(loadquest_report)
2895 {
2896 enter_sys_pal();
2897 AlertDialog("Quest saved in newer build",
2898 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2899 " issues loading in this build."
2900 "\n{}"
2901 "\n\nWould you like to continue loading anyway?",
2902 tempheader.getVerCmpStr()),
2903 [&](bool ret,bool)
2904 {
2905 r = ret;
2906 }).show();
2907 exit_sys_pal();
2908 }
2909 if(!r)
2910 return qe_silenterr;
2911 }
2912 //}
2913
2914 128 read_ext_zinfo = tempheader.external_zinfo;
2915
2916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(keepdata==true)
2917 {
2918 128 memcpy(Header, &tempheader, sizeof(tempheader));
2919 128 map_count=temp_map_count;
2920 128 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2921 128 }
2922
2923 128 return 0;
2924 128 }
2925
2926 99 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2927 {
2928 int32_t dummy;
2929 zquestheader tempheader;
2930 99 word s_version=0;
2931 99 dword compatrule_version=0;
2932
2933 99 memcpy(&tempheader, Header, sizeof(tempheader));
2934
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(tempheader.zelda_version >= 0x193)
2936 {
2937 //section version info
2938
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
2939 {
2940 return qe_invalid;
2941 }
2942
2943 99 FFCore.quest_format[vRules] = s_version;
2944
2945
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
2946 {
2947 return qe_invalid;
2948 }
2949
2950
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version > 16)
2951 {
2952
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&compatrule_version,f,true))
2953 {
2954 return qe_invalid;
2955 }
2956 22 }
2957 99 FFCore.quest_format[vCompatRule] = compatrule_version;
2958
2959 //section size
2960
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
2961 {
2962 return qe_invalid;
2963 }
2964
2965
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if ( s_version < 15 )
2966 {
2967 //finally... section data
2968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2969 {
2970 return qe_invalid;
2971 }
2972 77 }
2973 else
2974 {
2975
2976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2977 {
2978 return qe_invalid;
2979 }
2980
2981 }
2982 99 }
2983
2984 //al_trace("Rules version %d\n", s_version);
2985 //{ bunch of compat stuff
2986 99 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2987
2988
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
2989 {
2990 3 set_bit(quest_rules,14,0);
2991 3 set_bit(quest_rules,27,0);
2992 3 set_bit(quest_rules,28,0);
2993 3 set_bit(quest_rules,29,0);
2994 3 set_bit(quest_rules,30,0);
2995 3 set_bit(quest_rules,32,0);
2996 3 set_bit(quest_rules,36,0);
2997 3 set_bit(quest_rules,49,0);
2998 3 set_bit(quest_rules,50,0);
2999 3 set_bit(quest_rules,51,0);
3000 3 set_bit(quest_rules,68,0);
3001 3 set_bit(quest_rules,75,0);
3002 3 set_bit(quest_rules,76,0);
3003 3 set_bit(quest_rules,98,0);
3004 3 set_bit(quest_rules,110,0);
3005 3 set_bit(quest_rules,113,0);
3006 3 set_bit(quest_rules,116,0);
3007 3 set_bit(quest_rules,102,0);
3008 3 set_bit(quest_rules,132,0);
3009 3 }
3010
3011 //Now, do any updates...
3012
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3013 {
3014 3 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3015 3 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3016 3 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3017 3 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3018 3 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3019 3 }
3020
3021
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3022 {
3023 set_bit(quest_rules,qr_WALLFLIERS,1);
3024 }
3025
3026
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3027 {
3028 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3029 }
3030
3031
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3032 {
3033 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3034 }
3035
3036
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3037 {
3038 3 set_bit(quest_rules,qr_ARROWCLIP,1);
3039 3 }
3040
3041
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3042 {
3043 3 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3044 3 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3045 3 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3046 3 }
3047
3048
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3049 {
3050 3 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3051 3 set_bit(quest_rules,qr_210_WARPRETURN,1);
3052 3 }
3053
3054 //might not be correct
3055
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x210)
3056 {
3057 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3058 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3059 }
3060
3061
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x211)
3062 {
3063 3 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3064 3 }
3065
3066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3067 {
3068 set_bit(quest_rules, qr_192b163_WARP,1);
3069 }
3070
3071
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3072 {
3073 3 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3074 3 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3075 3 }
3076
3077
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3078 {
3079 3 set_bit(quest_rules, qr_OLDPICKUP,1);
3080 3 }
3081
3082
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3083 {
3084 3 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3085 3 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3086 3 }
3087
3088
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3089 {
3090 3 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3091 3 }
3092
3093
4/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 22 times.
99 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3094 {
3095 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3096 22 }
3097
3098
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3099 {
3100 3 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3101 3 }
3102
3103
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3104 {
3105 3 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3106 3 }
3107
3108
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3109 {
3110 25 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3111 25 }
3112
3113
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3114 {
3115 25 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3116 25 }
3117
3118 //Bombchu fix.
3119
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if(tempheader.zelda_version == 0x250)
3120 {
3121
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 22 times.
74 if ( tempheader.build == 24 ) //2.50.0
3122 {
3123 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3124 22 }
3125
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5 times.
74 if ( tempheader.build == 28 ) //2.50.1
3126 {
3127 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3128 5 }
3129
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
74 if ( tempheader.build == 29 ) //2.50.2
3130 {
3131 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3132 24 }
3133
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( tempheader.build == 30 ) //2.50.3RC1
3134 {
3135 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3136 }
3137 74 }
3138
3139
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3140 {
3141 // qr_OFFSETEWPNCOLLISIONFIX
3142 // All 'official' quests need this disabled.
3143 // All 2.10 and lower quests need this enabled to preseve compatability.
3144 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3145
3146 //~Gleeok
3147 30 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3148
3149 // Broke in build 695
3150
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
30 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3151 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3152 30 }
3153
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (tempheader.zelda_version <= 0x190)
3154 {
3155 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3156 }
3157
7/10
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 22 times.
99 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3158 {
3159 77 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3160 77 }
3161
3162
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3163 {
3164 3 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3165 3 }
3166
3167
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3168 {
3169 77 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3170 77 }
3171
3172
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( tempheader.zelda_version < 0x250 )
3173 {
3174 3 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3175 3 }
3176
3177
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 3)
3178 {
3179 3 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3180 3 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3181 3 }
3182
3183
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<4)
3184 {
3185 3 set_bit(quest_rules,10,0);
3186 3 }
3187
3188
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
3189 {
3190 3 set_bit(quest_rules,27,0);
3191 3 }
3192
3193
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<6)
3194 {
3195 3 set_bit(quest_rules,46,0);
3196 3 }
3197
3198
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<7) // January 2008
3199 {
3200 3 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3201 3 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3202 3 }
3203
3204
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version<8)
3205 {
3206 3 set_bit(quest_rules, 12, 0);
3207 3 }
3208 else
3209 {
3210 96 set_bit(deprecated_rules, 12, 0);
3211 }
3212
3213
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<9) // October 2008
3214 {
3215 3 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3216 3 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3217 3 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3218 3 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3219 3 }
3220
3221
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<10) // December 2008
3222 {
3223 3 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3224 3 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3225 3 }
3226
3227
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<11) // April 2009
3228 {
3229 3 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3230 3 }
3231
3232
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<12) // December 2009
3233 {
3234 3 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3235 3 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3236 3 }
3237
3238 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3239
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 13)
3240 {
3241 3 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3242 3 }
3243
3244 // Not entirely sure this is the best place for this...
3245 //2.50.2 bitmap offset fix
3246 99 memset(extra_rules, 0, EXTRARULES_SIZE);
3247
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3248 {
3249 30 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3250 30 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3251 30 }
3252 //required because quest templates also used this bit, although
3253 //it never did anything, before. -Z
3254
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if ( tempheader.zelda_version == 0x250 )
3255 {
3256
5/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 35 times.
74 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3257 {
3258 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3259 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3260 39 }
3261 74 }
3262
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if ( tempheader.zelda_version == 0x254 )
3263 {
3264 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3265 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3266 }
3267
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
99 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3268 {
3269 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3270 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3271 }
3272 //optimise fast drawing for older versions.
3273
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3274 {
3275 77 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3276 77 }
3277 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3278 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3279 //older quests can set the rule by hand. We need a new qst.dat again.
3280
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3281 {
3282 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3283 }
3284
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3285 {
3286 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3287 }
3288
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3289 {
3290 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3291 }
3292
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3293 {
3294 77 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3295 77 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3296 77 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3297 77 }
3298
3299 //item scripts continue to run
3300
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3301 {
3302 77 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3303 77 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3304 77 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3305 77 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3306 77 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3307 77 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3308 77 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3309 77 }
3310
3311
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3312 {
3313 77 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3314 77 }
3315
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3316 {
3317 77 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3318 77 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3319 77 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3320 77 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3321 77 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3322 77 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3323 77 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3324 77 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3325
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 1 times.
77 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3326 {
3327 1 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3328 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3329 //Now they **do**, unless you disable that behaviour.
3330 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3331 //now enable the disable L/R item swap on load.
3332 1 }
3333
3334 77 }
3335
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3336 {
3337 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3338 77 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3339 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3340 //animations ending earlier than they should.
3341 77 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3342 //Enemies would ignore solidity on the top half of combos
3343 77 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3344 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3345 77 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3346 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3347 77 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3348 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3349 77 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3350 77 }
3351
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x255 )
3352 {
3353 77 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3354 77 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3355 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3356 77 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3357 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3358 77 }
3359
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3360 {
3361 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3362 77 }
3363
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3364 {
3365 77 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3366 77 }
3367
3368
3369
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3370 {
3371 77 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3372 77 }
3373
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3374 {
3375 77 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3376 77 }
3377
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3378 {
3379 77 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3380 77 }
3381
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3382 {
3383 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3384
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3385 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3386 77 }
3387
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3388 {
3389 77 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3390 77 }
3391
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3392 {
3393 77 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3394 77 }
3395
3396
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3397 {
3398 77 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3399 77 }
3400 //Sideview spikes in 2.50.0
3401
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3402 {
3403 25 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3404 25 }
3405 //more 2.50 fixes -Z
3406
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 23 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3407 {
3408 54 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3409 54 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3410 54 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3411 54 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3412 54 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3413
3414 54 }
3415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3416 {
3417 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3418 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3419 }
3420
3421
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x193)
3422 {
3423 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3424 }
3425
3426
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(tempheader.zelda_version < 0x255)
3427 {
3428 77 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3429 77 }
3430
3431
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3432 {
3433 3 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3434 3 }
3435
3436
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3437 {
3438 77 set_bit(quest_rules,qr_OLD_F6,1);
3439 77 }
3440
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3441 {
3442 77 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3443 77 }
3444
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3445 {
3446 77 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3447 77 }
3448
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3449 {
3450 77 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3451 77 }
3452 //}
3453
3454
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3455 77 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3456
3457
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 2) //Old CSet2 Handling
3458 77 set_bit(quest_rules,qr_OLDCS2,1);
3459
3460
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3461 77 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3462
3463
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3464 77 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3465
3466
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 74 times.
99 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3467 74 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3468
3469
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3470 77 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3471
3472
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3473 77 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3474
3475
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3476 77 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3477
3478
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 9)
3479 {
3480 //Hardcoded BS Patras
3481 77 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3482 //Hardcoded Patra Inner Eye offsets
3483 77 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3484 //Broken 'Big enemy' animation style
3485 77 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3486 //Broken Attribute 31/32
3487 77 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3488 77 }
3489
3490
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 10) //Shared candle use limits
3491 77 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3492
3493
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 11) //No cross-screen return points
3494 77 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3495
3496
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 12)
3497 {
3498 //Old fire trail duration
3499 77 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3500 //Old Intro String in Ganon Room Behavior
3501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3502 77 else set_bit(quest_rules,qr_GANONINTRO,1);
3503 77 }
3504
3505
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
99 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3506 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3507
3508
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 14) //Old Bridge Combo Behavior
3509 77 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3510
3511
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 15) //Broken Z3 Animation
3512 77 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3513
3514
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3515 77 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3516
3517
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 17)
3518 {
3519 //Old Quake/DrawYOffset behavior
3520 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3521 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3522 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3523 77 }
3524
3525
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 18)
3526 {
3527 //Broken DrawScreen Derivative Functions
3528 77 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3529 //Scrolling Cancels Charge
3530 77 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3531 77 }
3532
3533
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3534 77 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3535
3536
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 20)
3537 77 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3538
3539
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 21)
3540 {
3541 77 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3542 77 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3543 77 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3544 77 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3545 77 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3546 77 }
3547
3548
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 22)
3549 77 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3550
3551
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 23)
3552 77 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3553
3554
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 24)
3555 {
3556 77 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3557 77 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3558 77 }
3559
3560
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 25)
3561 {
3562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3563 77 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3564 77 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3565 77 }
3566
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 26)
3567 {
3568 77 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3569 77 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3570 77 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3571 77 }
3572
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3573 {
3574
2/2
✓ Branch 0 taken 23177 times.
✓ Branch 1 taken 77 times.
23254 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3575 23177 set_bit(quest_rules,q,0);
3576
2/2
✓ Branch 0 taken 8624 times.
✓ Branch 1 taken 77 times.
8701 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3577 8624 set_bit(quest_rules,q,0);
3578 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3579 77 }
3580
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 28)
3581 79 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3582
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 29)
3583 79 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3584
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 30)
3585 {
3586 79 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3587 79 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3588 79 }
3589
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 31)
3590 {
3591 79 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3592 79 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3593 79 }
3594
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 32)
3595 79 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3596
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 33)
3597 79 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3598
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(compatrule_version < 34)
3599 {
3600 86 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3601 86 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3602 86 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3603 86 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3604 86 }
3605
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 35)
3606 {
3607 // Leaving this commented for now, might need to enable later -Em
3608 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3609 88 }
3610
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 36)
3611 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(compatrule_version < 37)
3613 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(compatrule_version < 38)
3615 99 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3616
3617 99 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3618
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if (s_version < 16)
3619 77 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
3622 99 memcpy(Header, &tempheader, sizeof(tempheader));
3623
3624 99 return 0;
3625 99 }
3626
3627 816980 void init_msgstr(MsgStr *str)
3628 {
3629 816980 str->s = "";
3630 816980 str->s.shrink_to_fit();
3631 816980 str->nextstring=0;
3632 816980 str->tile=0;
3633 816980 str->cset=0;
3634 816980 str->trans=false;
3635 816980 str->font=font_zfont;
3636 816980 str->y=32;
3637 816980 str->sfx=18;
3638 816980 str->listpos=0;
3639 816980 str->x=24;
3640 816980 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3641 816980 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3642 816980 str->hspace=0;
3643 816980 str->vspace=0;
3644 816980 str->stringflags=0;
3645 816980 str->margins[up] = 8;
3646 816980 str->margins[down] = 0;
3647 816980 str->margins[left] = 8;
3648 816980 str->margins[right] = 0;
3649 816980 str->portrait_tile = 0;
3650 816980 str->portrait_cset = 0;
3651 816980 str->portrait_x = 0;
3652 816980 str->portrait_y = 0;
3653 816980 str->portrait_tw = 1;
3654 816980 str->portrait_th = 1;
3655 816980 str->shadow_type = 0;
3656 816980 str->shadow_color = 0;
3657 816980 str->drawlayer = 6;
3658 816980 }
3659
3660 99 void init_msgstrings(int32_t start, int32_t end)
3661 {
3662
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(end <= start || end-start > msg_strings_size)
3663 return;
3664
3665
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 99 times.
811107 for(int32_t i=start; i<end; i++)
3666 {
3667 811008 init_msgstr(&MsgStrings[i]);
3668 811008 MsgStrings[i].listpos=i;
3669 811008 }
3670
3671
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(start==0)
3672 {
3673 99 MsgStrings[0].s = "(None)";
3674 99 MsgStrings[0].listpos = 0;
3675 99 }
3676 99 }
3677
3678 99 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3679 {
3680 99 MsgStr tempMsgString;
3681
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstr(&tempMsgString);
3682
3683 99 word temp_msg_count=0;
3684 word temp_expansion[16];
3685 99 memset(temp_expansion, 0, 16*sizeof(word));
3686 99 char buf[8193] = {0};
3687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
3688 {
3689 byte tempbyte;
3690 int32_t strings_to_read=0;
3691 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3692 if((Header->zelda_version < 0x192)||
3693 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3694 {
3695 strings_to_read=128;
3696 temp_msg_count=Header->old_str_count;
3697
3698 // Some sort of string count corruption seems to be common in old quests
3699 if(temp_msg_count>128)
3700 {
3701 temp_msg_count=128;
3702 }
3703 }
3704 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3705 {
3706 strings_to_read=255;
3707 temp_msg_count=Header->old_str_count;
3708 }
3709 else
3710 {
3711 if(!p_igetw(&temp_msg_count,f,true))
3712 {
3713 return qe_invalid;
3714 }
3715
3716 strings_to_read=temp_msg_count;
3717
3718 if(temp_msg_count >= msg_strings_size)
3719 {
3720 Z_message("Reallocating string buffer...\n");
3721
3722 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3723 // return qe_nomem;
3724
3725 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3726 delete[] MsgStrings;
3727 MsgStrings = new MsgStr[MAXMSGS];
3728 msg_strings_size = MAXMSGS;
3729 for(auto q = 0; q < msg_strings_size; ++q)
3730 {
3731 MsgStrings[q].clear();
3732 }
3733 }
3734 }
3735
3736 //reset the message strings
3737 if(keepdata)
3738 {
3739 init_msgstrings(0,msg_strings_size);
3740 }
3741
3742 for(int32_t x=0; x<strings_to_read; x++)
3743 {
3744 init_msgstr(&tempMsgString);
3745
3746 if(!pfread(buf,73,f,true))
3747 {
3748 return qe_invalid;
3749 }
3750
3751 buf[74] = '\0';
3752 tempMsgString.s = buf;
3753
3754 if(!p_getc(&tempbyte,f,true))
3755 {
3756 return qe_invalid;
3757 }
3758
3759 if((Header->zelda_version < 0x192)||
3760 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3761 {
3762 tempMsgString.nextstring=tempbyte?x+1:0;
3763
3764 if(!p_getc(&tempbyte,f,true))
3765 {
3766 return qe_invalid;
3767 }
3768
3769 if(!p_getc(&tempbyte,f,true))
3770 {
3771 return qe_invalid;
3772 }
3773 }
3774 else
3775 {
3776 if(!p_igetw(&tempMsgString.nextstring,f,true))
3777 {
3778 return qe_invalid;
3779 }
3780
3781 if(!pfread(temp_expansion,32,f,true))
3782 {
3783 return qe_invalid;
3784 }
3785 }
3786
3787 if(keepdata==true)
3788 {
3789 MsgStrings[x] = tempMsgString;
3790 }
3791 }
3792 }
3793 else
3794 {
3795 int32_t dummy_int;
3796 word s_version;
3797 word s_cversion;
3798
3799 //section version info
3800
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
3801 {
3802 return qe_invalid;
3803 }
3804
3805 99 FFCore.quest_format[vStrings] = s_version;
3806
3807
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
3808 {
3809 return qe_invalid;
3810 }
3811
3812 //al_trace("Strings version %d\n", s_version);
3813 //section size
3814
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy_int,f,true))
3815 {
3816 return qe_invalid;
3817 }
3818
3819 //finally... section data
3820
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_msg_count,f,true))
3821 {
3822 return qe_invalid;
3823 }
3824
3825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(temp_msg_count >= msg_strings_size)
3826 {
3827 Z_message("Reallocating string buffer...\n");
3828
3829 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3830 // return qe_nomem;
3831 delete[] MsgStrings;
3832 MsgStrings = new MsgStr[MAXMSGS];
3833 msg_strings_size = MAXMSGS;
3834 for(auto q = 0; q < msg_strings_size; ++q)
3835 {
3836 MsgStrings[q].clear();
3837 }
3838 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3839 }
3840
3841 //reset the message strings
3842
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata)
3843 {
3844
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 7)
3845
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3846
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstrings(0,msg_strings_size);
3847 99 }
3848
3849 99 int32_t string_length=(s_version<2)?73:145;
3850
3851
2/2
✓ Branch 0 taken 5873 times.
✓ Branch 1 taken 99 times.
5972 for(int32_t i=0; i<temp_msg_count; i++)
3852 {
3853
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 init_msgstr(&tempMsgString);
3854
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 5013 times.
5873 if(s_version > 8)
3855 {
3856
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&string_length,f,true))
3857 {
3858 return qe_invalid;
3859 }
3860 860 }
3861
2/2
✓ Branch 0 taken 5735 times.
✓ Branch 1 taken 138 times.
5873 if (string_length > 0)
3862 {
3863
2/4
✓ Branch 0 taken 5735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5735 times.
✗ Branch 3 not taken.
5735 if (!pfread(buf, string_length, f, true))
3864 {
3865 return qe_invalid;
3866 }
3867 5735 }
3868 else
3869 {
3870 138 buf[0] = 0;
3871 }
3872
3873
2/4
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5873 times.
✗ Branch 3 not taken.
5873 if(!p_igetw(&tempMsgString.nextstring,f,true))
3874 {
3875 return qe_invalid;
3876 }
3877
3878
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 5357 times.
5873 if(s_version<2)
3879 {
3880 516 buf[72] = '\0';
3881
1/2
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
516 tempMsgString.s = buf;
3882 516 }
3883 else
3884 {
3885 // June 2008: A bug corrupted the last 4 chars of a string.
3886 // Discard these.
3887
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version<3)
3888 {
3889 for(int32_t j=140; j<144; j++)
3890 {
3891 buf[j] = '\0';
3892 }
3893 }
3894
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(string_length > 8192) string_length = 8192;
3895 5357 buf[string_length]='\0'; //Force-terminate
3896
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 tempMsgString.s = buf;
3897
3898
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if ( s_version >= 6 )
3899 {
3900
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.tile,f,true))
3901 {
3902 return qe_invalid;
3903 }
3904 860 }
3905 else
3906 {
3907
2/4
✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4497 times.
✗ Branch 3 not taken.
4497 if(!p_igetw(&tempMsgString.tile,f,true))
3908 {
3909 return qe_invalid;
3910 }
3911 }
3912
3913
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.cset,f,true))
3914 {
3915 return qe_invalid;
3916 }
3917
3918 byte dummy_char;
3919
3920
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3921 {
3922 return qe_invalid;
3923 }
3924
3925 5357 tempMsgString.trans=dummy_char!=0;
3926
3927
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.font,f,true))
3928 {
3929 return qe_invalid;
3930 }
3931
3932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5357 times.
5357 if(s_version < 5)
3933 {
3934 if(!p_getc(&tempMsgString.y,f,true))
3935 {
3936 return qe_invalid;
3937 }
3938 }
3939 else
3940 {
3941
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.x,f,true))
3942 {
3943 return qe_invalid;
3944 }
3945
3946
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.y,f,true))
3947 {
3948 return qe_invalid;
3949 }
3950
3951
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.w,f,true))
3952 {
3953 return qe_invalid;
3954 }
3955
3956
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.h,f,true))
3957 {
3958 return qe_invalid;
3959 }
3960
3961
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.hspace,f,true))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.vspace,f,true))
3967 {
3968 return qe_invalid;
3969 }
3970
3971
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.stringflags,f,true))
3972 {
3973 return qe_invalid;
3974 }
3975 }
3976
3977
2/2
✓ Branch 0 taken 4497 times.
✓ Branch 1 taken 860 times.
5357 if(s_version >= 7)
3978 {
3979
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 3440 times.
4300 for(int32_t q = 0; q < 4; ++q)
3980 {
3981
2/4
✓ Branch 0 taken 3440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3440 times.
✗ Branch 3 not taken.
3440 if(!p_getc(&tempMsgString.margins[q],f,true))
3982 {
3983 return qe_invalid;
3984 }
3985 3440 }
3986
3987
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
3988 {
3989 return qe_invalid;
3990 }
3991
3992
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_cset,f,true))
3993 {
3994 return qe_invalid;
3995 }
3996
3997
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_x,f,true))
3998 {
3999 return qe_invalid;
4000 }
4001
4002
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_y,f,true))
4003 {
4004 return qe_invalid;
4005 }
4006
4007
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4008 {
4009 return qe_invalid;
4010 }
4011
4012
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_th,f,true))
4013 {
4014 return qe_invalid;
4015 }
4016 860 }
4017
4018
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if(s_version >= 8)
4019 {
4020
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_type,f,true))
4021 {
4022 return qe_invalid;
4023 }
4024
4025
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_color,f,true))
4026 {
4027 return qe_invalid;
4028 }
4029 860 }
4030
4031
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 4614 times.
5357 if(s_version >= 10)
4032 {
4033
2/4
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
743 if(!p_getc(&tempMsgString.drawlayer,f,true))
4034 {
4035 return qe_invalid;
4036 }
4037 743 }
4038
4039
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.sfx,f,true))
4040 {
4041 return qe_invalid;
4042 }
4043
4044
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version>3)
4045 {
4046
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.listpos,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050 5357 }
4051 }
4052
4053
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 if(keepdata==true)
4054 {
4055
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 MsgStrings[i].copyAll(tempMsgString);
4056 5873 }
4057 5873 }
4058 }
4059
4060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4061 {
4062 99 msg_count=temp_msg_count;
4063 99 }
4064
4065 99 return 0;
4066 99 }
4067
4068 99 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4069 {
4070
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
4071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4072 {
4073 return 0;
4074 }
4075
4076 99 word temp_door_combo_set_count=0;
4077 DoorComboSet tempDoorComboSet;
4078 word dummy_word;
4079 int32_t dummy_long;
4080 byte padding;
4081 99 int32_t s_version = 0;
4082
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4084 {
4085
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4086 {
4087 25344 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4088 25344 }
4089 99 }
4090
4091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
4092 {
4093 //section version info
4094
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4095 {
4096 return qe_invalid;
4097 }
4098
4099 99 FFCore.quest_format[vDoors] = s_version;
4100
4101 //al_trace("Door combo sets version %d\n", dummy_word);
4102
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy_word,f,true))
4103 {
4104 return qe_invalid;
4105 }
4106
4107 //section size
4108
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_long,f,true))
4109 {
4110 return qe_invalid;
4111 }
4112 99 }
4113
4114 //finally... section data
4115
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_door_combo_set_count,f,true))
4116 {
4117 return qe_invalid;
4118 }
4119
4120
2/2
✓ Branch 0 taken 727 times.
✓ Branch 1 taken 99 times.
826 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4121 {
4122 727 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4123
4124 //name
4125
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4126 {
4127 return qe_invalid;
4128 }
4129
4130
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4131 {
4132 if(!p_getc(&padding,f,true))
4133 {
4134 return qe_invalid;
4135 }
4136 }
4137
4138 //up door
4139
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4140 {
4141
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4142 {
4143
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4144 {
4145 return qe_invalid;
4146 }
4147 26172 }
4148 6543 }
4149
4150
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4151 {
4152
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4153 {
4154
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4155 {
4156 return qe_invalid;
4157 }
4158 26172 }
4159 6543 }
4160
4161 //down door
4162
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4163 {
4164
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4165 {
4166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26172 times.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4167 {
4168 return qe_invalid;
4169 }
4170 26172 }
4171 6543 }
4172
4173
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4174 {
4175
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4176 {
4177
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4178 {
4179 return qe_invalid;
4180 }
4181 26172 }
4182 6543 }
4183
4184 //left door
4185
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4186 {
4187
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4188 {
4189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39258 times.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4190 {
4191 return qe_invalid;
4192 }
4193 39258 }
4194 6543 }
4195
4196
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4197 {
4198
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4199 {
4200
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4201 {
4202 return qe_invalid;
4203 }
4204 39258 }
4205 6543 }
4206
4207 //right door
4208
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4209 {
4210
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4211 {
4212
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4213 {
4214 return qe_invalid;
4215 }
4216 39258 }
4217 6543 }
4218
4219
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4220 {
4221
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4222 {
4223
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4224 {
4225 return qe_invalid;
4226 }
4227 39258 }
4228 6543 }
4229
4230 //up bomb rubble
4231
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4232 {
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4234 {
4235 return qe_invalid;
4236 }
4237 1454 }
4238
4239
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4240 {
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4242 {
4243 return qe_invalid;
4244 }
4245 1454 }
4246
4247 //down bomb rubble
4248
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4249 {
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4251 {
4252 return qe_invalid;
4253 }
4254 1454 }
4255
4256
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4257 {
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4259 {
4260 return qe_invalid;
4261 }
4262 1454 }
4263
4264 //left bomb rubble
4265
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4266 {
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4268 {
4269 return qe_invalid;
4270 }
4271 2181 }
4272
4273
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4276 {
4277 return qe_invalid;
4278 }
4279 2181 }
4280
4281
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4282 {
4283 if(!p_getc(&padding,f,true))
4284 {
4285 return qe_invalid;
4286 }
4287
4288 }
4289
4290 //right bomb rubble
4291
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4292 {
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4294 {
4295 return qe_invalid;
4296 }
4297 2181 }
4298
4299
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4302 {
4303 return qe_invalid;
4304 }
4305 2181 }
4306
4307
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4308 {
4309 if(!p_getc(&padding,f,true))
4310 {
4311 return qe_invalid;
4312 }
4313 }
4314
4315 //walkthrough stuff
4316
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4317 {
4318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4319 {
4320 return qe_invalid;
4321 }
4322 2908 }
4323
4324
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4325 {
4326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4327 {
4328 return qe_invalid;
4329 }
4330 2908 }
4331
4332 //flags
4333
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4334 {
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4336 {
4337 return qe_invalid;
4338 }
4339 1454 }
4340
4341
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4342 {
4343 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4344 {
4345 return qe_invalid;
4346 }
4347 }
4348
4349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 if(keepdata==true)
4350 {
4351 727 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4352 727 }
4353 727 }
4354
4355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4356 {
4357 99 door_combo_set_count=temp_door_combo_set_count;
4358 99 }
4359
4360 99 return 0;
4361 99 }
4362
4363 int32_t count_dmaps()
4364 {
4365 int32_t i=MAXDMAPS-1;
4366 bool found=false;
4367
4368 while(i>=0 && !found)
4369 {
4370 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4371 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4372 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4373 found=true;
4374
4375 for(int32_t j=0; j<8; j++)
4376 {
4377 if(DMaps[i].grid[j]!=0)
4378
4379 found=true;
4380 }
4381
4382 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4383 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4384 found=true;
4385
4386 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4387 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4388 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4389 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4390 found=true;
4391
4392 if(!found)
4393 {
4394 i--;
4395 }
4396 }
4397
4398 return i+1;
4399 }
4400
4401
4402 int32_t count_shops(miscQdata *Misc)
4403 {
4404 int32_t i=255,j;
4405 bool found=false;
4406
4407 while(i>=0 && !found)
4408 {
4409 j=2;
4410
4411 while(j>=0 && !found)
4412 {
4413 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4414 {
4415 found=true;
4416 }
4417 else
4418 {
4419 j--;
4420 }
4421 }
4422
4423 if(Misc->shop[i].name[0]!=0)
4424 {
4425 found=true;
4426 }
4427
4428 if(!found)
4429 {
4430 i--;
4431 }
4432 }
4433
4434 return i+1;
4435 }
4436
4437 int32_t count_infos(miscQdata *Misc)
4438 {
4439 int32_t i=255,j;
4440 bool found=false;
4441
4442 while(i>=0 && !found)
4443 {
4444 j=2;
4445
4446 while(j>=0 && !found)
4447 {
4448 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4449 {
4450 found=true;
4451 }
4452 else
4453 {
4454 j--;
4455 }
4456 }
4457
4458 if(Misc->info[i].name[0]!=0)
4459 {
4460 found=true;
4461 }
4462
4463 if(!found)
4464 {
4465 i--;
4466 }
4467 }
4468
4469 return i+1;
4470 }
4471
4472 int32_t count_warprings(miscQdata *Misc)
4473 {
4474 int32_t i=15,j;
4475 bool found=false;
4476
4477 while(i>=0 && !found)
4478 {
4479 j=7;
4480
4481 while(j>=0 && !found)
4482 {
4483 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4484 {
4485 found=true;
4486 }
4487 else
4488 {
4489 j--;
4490 }
4491 }
4492
4493 if(!found)
4494 {
4495 i--;
4496 }
4497 }
4498
4499 return i+1;
4500 }
4501
4502 int32_t count_palcycles(miscQdata *Misc)
4503 {
4504 int32_t i=255,j;
4505 bool found=false;
4506
4507 while(i>=0 && !found)
4508 {
4509 j=2;
4510
4511 while(j>=0 && !found)
4512 {
4513 if(Misc->cycles[i][j].count!=0)
4514 {
4515 found=true;
4516 }
4517 else
4518 {
4519 j--;
4520 }
4521 }
4522
4523 if(!found)
4524 {
4525 i--;
4526 }
4527 }
4528
4529 return i+1;
4530 }
4531
4532 158267 void clear_screen(mapscr *temp_scr)
4533 {
4534 158267 temp_scr->zero_memory();
4535 158267 }
4536
4537 99 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4538 {
4539 99 word dmapstoread=0;
4540 dmap tempDMap;
4541
4542 int32_t dummy;
4543 99 word s_version=0, s_cversion=0;
4544 byte padding;
4545
4546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4547 {
4548
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<max_dmaps; i++)
4549 {
4550 50688 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4551 50688 sprintf(DMaps[start_dmap+i].title," ");
4552 50688 sprintf(DMaps[start_dmap+i].intro," ");
4553 50688 DMaps[start_dmap+i].type |= dmCAVE;
4554 50688 }
4555 99 }
4556
4557
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!Header || Header->zelda_version > 0x192)
4558 {
4559 //section version info
4560
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4561 {
4562 return qe_invalid;
4563 }
4564
4565 99 FFCore.quest_format[vDMaps] = s_version;
4566
4567 //al_trace("DMaps version %d\n", s_version);
4568
4569
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
4570 {
4571 return qe_invalid;
4572 }
4573
4574 //section size
4575
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
4576 {
4577 return qe_invalid;
4578 }
4579
4580 //finally... section data
4581
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dmapstoread,f,true))
4582 {
4583 return qe_invalid;
4584 }
4585 99 }
4586 else
4587 {
4588 if((Header->zelda_version < 0x192)||
4589 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4590 {
4591 dmapstoread=32;
4592 }
4593 else if(s_version <= 4)
4594 {
4595 dmapstoread=OLDMAXDMAPS;
4596 }
4597 else
4598 {
4599 dmapstoread=MAXDMAPS;
4600 }
4601 }
4602
4603
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, max_dmaps);
4604
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4605
4606
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4607 {
4608 49920 memset(&tempDMap,0,sizeof(dmap));
4609 49920 sprintf(tempDMap.title," ");
4610 49920 sprintf(tempDMap.intro," ");
4611
4612
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.map,f,keepdata))
4613 {
4614 return qe_invalid;
4615 }
4616
4617
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version <= 4)
4618 {
4619 byte tempbyte;
4620
4621
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,keepdata))
4622 {
4623 return qe_invalid;
4624 }
4625
4626 768 tempDMap.level=(word)tempbyte;
4627 768 }
4628 else
4629 {
4630
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.level,f,keepdata))
4631 {
4632 return qe_invalid;
4633 }
4634 }
4635
4636
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.xoff,f,keepdata))
4637 {
4638 return qe_invalid;
4639 }
4640
4641
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.compass,f,keepdata))
4642 {
4643 return qe_invalid;
4644 }
4645
4646
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version > 8) // February 2009
4647 {
4648
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.color,f,true))
4649 {
4650 return qe_invalid;
4651 }
4652 49152 }
4653 else
4654 {
4655 byte tempbyte;
4656
4657
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,true))
4658 {
4659 return qe_invalid;
4660 }
4661
4662 768 tempDMap.color = (word)tempbyte;
4663 }
4664
4665
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.midi,f,keepdata))
4666 {
4667 return qe_invalid;
4668 }
4669
4670
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.cont,f,keepdata))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.type,f,keepdata))
4676 {
4677 return qe_invalid;
4678 }
4679
4680
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 49551 times.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
50289 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4681
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4682 369 tempDMap.xoff = 0;
4683
4684
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 49920 times.
449280 for(int32_t j=0; j<8; j++)
4685 {
4686
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4687 {
4688 return qe_invalid;
4689 }
4690 399360 }
4691
4692
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4693 {
4694 if(tempDMap.level>0&&tempDMap.level<10)
4695 {
4696 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4697 }
4698
4699 if(i==0 && Header->zelda_version <= 0x190)
4700 {
4701 tempDMap.cont-=tempDMap.xoff;
4702 tempDMap.compass-=tempDMap.xoff;
4703 }
4704
4705 //forgotten -DD
4706 if(tempDMap.level==0)
4707 {
4708 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4709 }
4710 }
4711 else
4712 {
4713
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4714 {
4715 return qe_invalid;
4716 }
4717
4718
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4719 {
4720 return qe_invalid;
4721 }
4722
4723
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4724 {
4725 return qe_invalid;
4726 }
4727
4728
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4729 {
4730 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4731 if(keepdata==true)
4732 {
4733 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4734 }
4735
4736 continue;
4737 }
4738
4739
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4740 {
4741 if(!p_getc(&padding,f,keepdata))
4742 {
4743 return qe_invalid;
4744 }
4745 }
4746
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4747 {
4748
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4749 {
4750 return qe_invalid;
4751 }
4752 11264 }
4753 else
4754 {
4755
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4756 {
4757 return qe_invalid;
4758 }
4759 }
4760
4761
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4762 {
4763 return qe_invalid;
4764 }
4765
4766
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4767 {
4768 if(!p_getc(&padding,f,keepdata))
4769 {
4770 return qe_invalid;
4771 }
4772 }
4773
4774
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4775 {
4776
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4777 {
4778 return qe_invalid;
4779 }
4780 11264 }
4781 else
4782 {
4783
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4784 {
4785 return qe_invalid;
4786 }
4787 }
4788
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4789 {
4790 return qe_invalid;
4791 }
4792
4793
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4794 {
4795 if(!p_getc(&padding,f,keepdata))
4796 {
4797 return qe_invalid;
4798 }
4799 }
4800
4801
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4802 {
4803
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4804 {
4805 return qe_invalid;
4806 }
4807 11264 }
4808 else
4809 {
4810
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4811 {
4812 return qe_invalid;
4813 }
4814 }
4815
4816
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4817 {
4818 return qe_invalid;
4819 }
4820
4821
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4822 {
4823
4824 if(!p_getc(&padding,f,keepdata))
4825 {
4826 return qe_invalid;
4827 }
4828 }
4829
4830
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4831 {
4832
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4833 {
4834 return qe_invalid;
4835 }
4836 11264 }
4837 else
4838 {
4839
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4840 {
4841 return qe_invalid;
4842 }
4843 }
4844
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4845 {
4846 return qe_invalid;
4847 }
4848
4849
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4850 {
4851 return qe_invalid;
4852 }
4853 }
4854
4855
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>1)
4856 {
4857
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4858 {
4859 return qe_invalid;
4860 }
4861
4862
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4863 {
4864 return qe_invalid;
4865 }
4866
4867
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4868 {
4869 return qe_invalid;
4870 }
4871 49152 }
4872
4873
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>2)
4874 {
4875 byte di[32];
4876
4877
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(&di, 32, f, true)) return qe_invalid;
4878
4879
2/2
✓ Branch 0 taken 12582912 times.
✓ Branch 1 taken 49152 times.
12632064 for(int32_t j=0; j<MAXITEMS; j++)
4880 {
4881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12582912 times.
12582912 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4882 12582912 else tempDMap.disableditems[j]=0;
4883 12582912 }
4884 49152 }
4885
4886
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version >= 6)
4887 {
4888
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempDMap.flags,f,keepdata))
4889 {
4890 return qe_invalid;
4891 }
4892 49152 }
4893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 else if(s_version>3)
4894 {
4895 char temp;
4896
4897 if(!p_getc(&temp,f,keepdata))
4898 {
4899 return qe_invalid;
4900 }
4901
4902 tempDMap.flags = temp;
4903 }
4904
3/8
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 573 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
768 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4905 {
4906 573 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4907 573 }
4908 else
4909 195 tempDMap.flags=0;
4910
4911
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<7)
4912 {
4913
3/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 573 times.
✗ Branch 3 not taken.
768 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4914 573 tempDMap.flags|= dmfVIEWMAP;
4915 768 }
4916
4917
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<8)
4918 {
4919
4/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 531 times.
768 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4920 {
4921 531 tempDMap.type &= ~dmDNGN;
4922 531 tempDMap.type |= dmCAVE;
4923 531 }
4924
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 105 times.
237 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4925 {
4926 105 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4927 105 }
4928 768 }
4929
4930
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49920 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 49920 times.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4931 49920 && (Header->zelda_version < 0x193))
4932 {
4933 if(!p_getc(&padding,f,keepdata))
4934 {
4935 return qe_invalid;
4936 }
4937 }
4938
4939
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 10)
4940 {
4941
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempDMap.sideview,f,keepdata))
4942 {
4943 return qe_invalid;
4944 }
4945 11264 }
4946
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version < 10) tempDMap.sideview = 0;
4947
4948 //Dmap Scripts
4949
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 12)
4950 {
4951
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.script,f,keepdata))
4952 {
4953 return qe_invalid;
4954 }
4955
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
4956 {
4957
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
4958 {
4959 return qe_invalid;
4960 }
4961 90112 }
4962 11264 }
4963
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 12 )
4964 {
4965 38656 tempDMap.script = 0;
4966
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
4967 {
4968 309248 tempDMap.initD[q] = 0;
4969 309248 }
4970 38656 }
4971
4972
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 13)
4973 {
4974
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
4975 {
4976
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
4977 {
4978
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
4979 {
4980 return qe_invalid;
4981 }
4982 5857280 }
4983 90112 }
4984 11264 }
4985
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 13 )
4986 {
4987 38656 tempDMap.script = 0;
4988
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
4989 {
4990
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for ( int32_t w = 0; w < 65; w++ )
4991 20101120 tempDMap.initD_label[q][w] = 0;
4992 309248 }
4993 38656 }
4994
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 14)
4995 {
4996
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
4997 {
4998 return qe_invalid;
4999 }
5000
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5001 {
5002 return qe_invalid;
5003 }
5004
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5005 {
5006
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5007 {
5008 return qe_invalid;
5009 }
5010 90112 }
5011
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5012 {
5013
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5014 {
5015
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5016 {
5017 return qe_invalid;
5018 }
5019 5857280 }
5020 90112 }
5021 11264 }
5022 else
5023 {
5024 38656 tempDMap.active_sub_script = 0;
5025 38656 tempDMap.passive_sub_script = 0;
5026
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5027 {
5028 309248 tempDMap.sub_initD[q] = 0;
5029
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5030 20101120 tempDMap.sub_initD_label[q][w] = 0;
5031 309248 }
5032 }
5033
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 15)
5034 {
5035
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5036 {
5037 return qe_invalid;
5038 }
5039
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5040 {
5041
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5042 {
5043 return qe_invalid;
5044 }
5045 90112 }
5046
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5047 {
5048
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5049 {
5050
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5051 {
5052 return qe_invalid;
5053 }
5054 5857280 }
5055 90112 }
5056 11264 }
5057 else
5058 {
5059 38656 tempDMap.onmap_script = 0;
5060
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5061 {
5062 309248 tempDMap.onmap_initD[q] = 0;
5063
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5064 {
5065 20101120 tempDMap.onmap_initD_label[q][w] = 0;
5066 20101120 }
5067 309248 }
5068 }
5069
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 16)
5070 {
5071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11264 times.
11264 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5072 {
5073 return qe_invalid;
5074 }
5075 11264 }
5076 else
5077 {
5078 38656 tempDMap.mirrorDMap = -1;
5079 }
5080
5081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
5082 {
5083 49920 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5084 49920 }
5085 49920 }
5086
5087 99 return 0;
5088 99 }
5089
5090 96 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5091 {
5092 //these are here to bypass compiler warnings about unused arguments
5093 96 Header=Header;
5094
5095 miscQdata temp_misc;
5096 96 word s_version=0, s_cversion=0;
5097 96 int32_t tempsize=0;
5098 word dummyw;
5099
5100 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5101
5102 //section version info
5103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5104 {
5105 return qe_invalid;
5106 }
5107
5108 96 FFCore.quest_format[vColours] = s_version;
5109
5110 96 al_trace("Misc Colours section version: %d\n", s_version);
5111
5112 //al_trace("Misc. colors version %d\n", s_version);
5113
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5114 {
5115 return qe_invalid;
5116 }
5117
5118
5119 //section size
5120
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5121 {
5122 return qe_invalid;
5123 }
5124
5125 //finally... section data
5126 96 readsize=0;
5127
5128
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.text,f,true))
5129 {
5130 return qe_invalid;
5131 }
5132
5133
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.caption,f,true))
5134 {
5135 return qe_invalid;
5136 }
5137
5138
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5139 {
5140 return qe_invalid;
5141 }
5142
5143
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5144 {
5145 return qe_invalid;
5146 }
5147
5148
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5149 {
5150 return qe_invalid;
5151 }
5152
5153
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5154 {
5155 return qe_invalid;
5156 }
5157
5158
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5159 {
5160 return qe_invalid;
5161 }
5162
5163
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5164 {
5165 return qe_invalid;
5166 }
5167
5168
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5169 {
5170 return qe_invalid;
5171 }
5172
5173
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5174 {
5175 return qe_invalid;
5176 }
5177
5178
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5179 {
5180 return qe_invalid;
5181 }
5182
5183
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5189 {
5190 return qe_invalid;
5191 }
5192
5193
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5194 {
5195 return qe_invalid;
5196 }
5197
5198
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5199 {
5200 return qe_invalid;
5201 }
5202
5203
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5204 {
5205 return qe_invalid;
5206 }
5207
5208
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5209 {
5210 return qe_invalid;
5211 }
5212
5213
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5214 {
5215 return qe_invalid;
5216 }
5217
5218
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5219 {
5220 return qe_invalid;
5221 }
5222
5223
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5224 {
5225 return qe_invalid;
5226 }
5227
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version < 4)
5228 {
5229
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5230 return qe_invalid;
5231 74 temp_misc.colors.triforce_tile = dummyw;
5232
5233
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5234 return qe_invalid;
5235 74 temp_misc.colors.triframe_tile = dummyw;
5236
5237
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5238 return qe_invalid;
5239 74 temp_misc.colors.overworld_map_tile = dummyw;
5240
5241
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5242 return qe_invalid;
5243 74 temp_misc.colors.dungeon_map_tile = dummyw;
5244
5245
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5246 return qe_invalid;
5247 74 temp_misc.colors.blueframe_tile = dummyw;
5248
5249
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5250 return qe_invalid;
5251 74 temp_misc.colors.HCpieces_tile = dummyw;
5252 74 }
5253
5254
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 2)
5265 {
5266 temp_misc.colors.msgtext = 0x01;
5267 }
5268 else
5269 {
5270
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5271 {
5272 return qe_invalid;
5273 }
5274 }
5275
5276
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if ( s_version >= 3 ) //expanded tile pages to 825
5277 {
5278
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5304 {
5305 return qe_invalid;
5306 }
5307 22 }
5308
5309
5310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5311 {
5312 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5313 96 }
5314
5315 96 return 0;
5316 96 }
5317
5318 96 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5319 {
5320 miscQdata temp_misc;
5321 96 word s_version=0, s_cversion=0;
5322 byte icons;
5323 96 int32_t tempsize=0;
5324
5325 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5326
5327 //section version info
5328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5329 {
5330 return qe_invalid;
5331 }
5332
5333 96 FFCore.quest_format[vIcons] = s_version;
5334
5335 //al_trace("Game icons version %d\n", s_version);
5336
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5337 {
5338 return qe_invalid;
5339 }
5340
5341
5342 //section size
5343
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5344 {
5345 return qe_invalid;
5346 }
5347
5348 //finally... section data
5349 96 readsize=0;
5350
5351 96 icons=4;
5352
5353
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 10 )
5354 {
5355
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<icons; i++)
5356 {
5357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&temp_misc.icons[i],f,true))
5358 {
5359 return qe_invalid;
5360 }
5361 88 }
5362 22 }
5363 else
5364 {
5365
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<icons; i++)
5366 {
5367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(!p_igetw(&temp_misc.icons[i],f,true))
5368 {
5369 return qe_invalid;
5370 }
5371 296 }
5372 }
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5374 {
5375 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5376 96 }
5377
5378 96 return 0;
5379 96 }
5380
5381 99 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5382 {
5383 99 word maxinfos=256;
5384 99 word maxshops=256;
5385 99 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5386 99 word ponds=16, pondsize=72, expansionsize=98*2;
5387 byte tempbyte, padding;
5388 miscQdata temp_misc;
5389 99 word s_version=0, s_cversion=0;
5390 word swaptmp;
5391 99 int32_t tempsize=0;
5392
5393 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5394
5395
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5396 {
5397 25344 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5398 25344 }
5399
5400
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5401 {
5402 25344 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5403 25344 }
5404
5405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5406 {
5407 //section version info
5408
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
5409 {
5410 return qe_invalid;
5411 }
5412
5413 99 FFCore.quest_format[vMisc] = s_version;
5414
5415 //al_trace("Misc. data version %d\n", s_version);
5416
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5417 {
5418 return qe_invalid;
5419 }
5420
5421
5422 //section size
5423
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5424 {
5425 return qe_invalid;
5426 }
5427 99 }
5428
5429 //finally... section data
5430 99 readsize=0;
5431
5432 //shops
5433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5434 {
5435
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&shops,f,true))
5436 {
5437 return qe_invalid;
5438 }
5439 99 }
5440
5441
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 99 times.
1101 for(int32_t i=0; i<shops; i++)
5442 {
5443
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 6)
5444 {
5445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978 times.
978 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5446 {
5447 return qe_invalid;
5448 }
5449 978 }
5450
5451
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5452 {
5453
1/2
✓ Branch 0 taken 3006 times.
✗ Branch 1 not taken.
3006 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5454 {
5455 return qe_invalid;
5456 }
5457
5458
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 72 times.
3006 if(s_version < 4)
5459 {
5460 72 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5461 72 }
5462 3006 }
5463
5464
1/2
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
1002 if(Header->zelda_version < 0x193)
5465 {
5466 if(!p_getc(&tempbyte,f,true))
5467 {
5468 return qe_invalid;
5469 }
5470 }
5471
5472
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5473 {
5474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3006 times.
3006 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5475 {
5476 return qe_invalid;
5477 }
5478 3006 }
5479
5480
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 3)
5481 {
5482
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
5483 {
5484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5485 return qe_invalid;
5486 2934 }
5487 978 }
5488
5489 /*
5490 if(s_version < 8)
5491 {
5492 for(int32_t j=0; j<3; j++)
5493 {
5494 (&temp_misc.shop[i].str[j])=0; //initialise.
5495 }
5496 }
5497 */
5498 1002 }
5499
5500 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5501
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5502 {
5503
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5504 {
5505
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5506 {
5507
2/2
✓ Branch 0 taken 2146 times.
✓ Branch 1 taken 73886 times.
76032 if(temp_misc.shop[i].hasitem[k]==0)
5508 {
5509 73886 swaptmp = temp_misc.shop[i].item[k];
5510 73886 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5511 73886 temp_misc.shop[i].item[k+1] = swaptmp;
5512 73886 swaptmp = temp_misc.shop[i].price[k];
5513 73886 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5514 73886 temp_misc.shop[i].price[k+1] = swaptmp;
5515 73886 swaptmp = temp_misc.shop[i].hasitem[k];
5516 73886 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5517 73886 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5518 73886 }
5519 76032 }
5520 50688 }
5521 25344 }
5522
5523 //infos
5524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5525 {
5526
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&infos,f,true))
5527 {
5528 return qe_invalid;
5529 }
5530 99 }
5531
5532
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 99 times.
1532 for(int32_t i=0; i<infos; i++)
5533 {
5534
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1424 times.
1433 if(s_version > 6)
5535 {
5536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1424 times.
1424 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5537 {
5538 return qe_invalid;
5539 }
5540 1424 }
5541
5542
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5543 {
5544
1/4
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4299 if((Header->zelda_version < 0x192)||
5545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5546 {
5547 if(!p_getc(&tempbyte,f,true))
5548 {
5549 return qe_invalid;
5550 }
5551
5552 temp_misc.info[i].str[j]=tempbyte;
5553 }
5554 else
5555 {
5556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5557 {
5558 return qe_invalid;
5559 }
5560 }
5561 4299 }
5562
5563
1/2
✓ Branch 0 taken 1433 times.
✗ Branch 1 not taken.
1433 if(Header->zelda_version < 0x193)
5564 {
5565 if(!p_getc(&tempbyte,f,true))
5566 {
5567 return qe_invalid;
5568 }
5569 }
5570
5571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1433 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1433 if((Header->zelda_version == 0x192)&&(Header->build>145))
5572 {
5573 if(!p_getc(&padding,f,true))
5574 {
5575 return qe_invalid;
5576 }
5577 }
5578
5579
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5580 {
5581
1/2
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
4299 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5582 {
5583 return qe_invalid;
5584 }
5585 4299 }
5586 1433 }
5587
5588 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5589
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5590 {
5591
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5592 {
5593
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5594 {
5595
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 74304 times.
76032 if(temp_misc.info[i].str[k]==0)
5596 {
5597 74304 swaptmp = temp_misc.info[i].str[k];
5598 74304 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5599 74304 temp_misc.info[i].str[k+1] = swaptmp;
5600 74304 swaptmp = temp_misc.info[i].price[k];
5601 74304 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5602 74304 temp_misc.info[i].price[k+1] = swaptmp;
5603 74304 }
5604 76032 }
5605 50688 }
5606 25344 }
5607
5608
5609 //warp rings
5610
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version > 5)
5611 96 warprings++;
5612
5613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5614 {
5615
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&warprings,f,true))
5616 {
5617 return qe_invalid;
5618 }
5619 99 }
5620
5621
2/2
✓ Branch 0 taken 958 times.
✓ Branch 1 taken 99 times.
1057 for(int32_t i=0; i<warprings; i++)
5622 {
5623
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5624 {
5625
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 8190 times.
8574 if(s_version <= 3)
5626 {
5627
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f,true))
5628 {
5629 return qe_invalid;
5630 }
5631
5632 384 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5633 384 }
5634 else
5635 {
5636
1/2
✓ Branch 0 taken 8190 times.
✗ Branch 1 not taken.
8190 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5637 {
5638 return qe_invalid;
5639 }
5640 }
5641 8574 }
5642
5643
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5644 {
5645
1/2
✓ Branch 0 taken 8574 times.
✗ Branch 1 not taken.
8574 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5646 {
5647 return qe_invalid;
5648 }
5649 8574 }
5650
5651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 958 times.
958 if(!p_getc(&temp_misc.warp[i].size,f,true))
5652 {
5653 return qe_invalid;
5654 }
5655
5656
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if(Header->zelda_version < 0x193)
5657 {
5658 if(!p_getc(&tempbyte,f,true))
5659 {
5660 return qe_invalid;
5661 }
5662 }
5663 958 }
5664
5665 //palette cycles
5666
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5667 {
5668 for(int32_t i=0; i<256; i++)
5669 {
5670 for(int32_t j=0; j<3; j++)
5671 {
5672 temp_misc.cycles[i][j].first=0;
5673 temp_misc.cycles[i][j].count=0;
5674 temp_misc.cycles[i][j].speed=0;
5675 }
5676 }
5677
5678 if((Header->zelda_version < 0x192)||
5679 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5680 {
5681 palcycles=16;
5682 }
5683
5684 for(int32_t i=0; i<palcycles; i++)
5685 {
5686 for(int32_t j=0; j<3; j++)
5687 {
5688 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5689 {
5690 return qe_invalid;
5691 }
5692
5693 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5694 {
5695 return qe_invalid;
5696 }
5697
5698 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5699 {
5700 return qe_invalid;
5701 }
5702 }
5703 }
5704 }
5705
5706 //Wind warps are now just another warp ring.
5707
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version <= 5)
5708 {
5709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(Header->zelda_version > 0x192)
5710 {
5711
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&windwarps,f,true))
5712 {
5713 return qe_invalid;
5714 }
5715 3 }
5716
5717
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
30 for(int32_t i=0; i<windwarps; i++)
5718 {
5719
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version <= 3)
5720 {
5721
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&tempbyte,f,true))
5722 {
5723 return qe_invalid;
5724 }
5725
5726 27 temp_misc.warp[8].dmap[i]=tempbyte;
5727 27 }
5728 else
5729 {
5730 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5731 {
5732 return qe_invalid;
5733 }
5734 }
5735
5736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5737 {
5738 return qe_invalid;
5739 }
5740
5741 27 temp_misc.warp[8].size = 9;
5742
5743
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version == 5)
5744 {
5745 if(!p_getc(&tempbyte,f,true))
5746 {
5747 return qe_invalid;
5748 }
5749 }
5750 27 }
5751 3 }
5752
5753
5754 //triforce pieces
5755
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<triforces; i++)
5756 {
5757
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_misc.triforce[i],f,true))
5758 {
5759 return qe_invalid;
5760 }
5761 792 }
5762
5763 //misc color data
5764
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<3)
5765 {
5766
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.text,f,true))
5767 {
5768 return qe_invalid;
5769 }
5770
5771
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.caption,f,true))
5772 {
5773 return qe_invalid;
5774 }
5775
5776
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5777 {
5778 return qe_invalid;
5779 }
5780
5781
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5782 {
5783 return qe_invalid;
5784 }
5785
5786
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5787 {
5788 return qe_invalid;
5789 }
5790
5791
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5792 {
5793 return qe_invalid;
5794 }
5795
5796
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5797 {
5798 return qe_invalid;
5799 }
5800
5801
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5802 {
5803 return qe_invalid;
5804 }
5805
5806
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5807 {
5808 return qe_invalid;
5809 }
5810
5811
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5812 {
5813 return qe_invalid;
5814 }
5815
5816
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5817 {
5818 return qe_invalid;
5819 }
5820
5821
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5822 {
5823 return qe_invalid;
5824 }
5825
5826
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5827 {
5828 return qe_invalid;
5829 }
5830
5831
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5832 {
5833 return qe_invalid;
5834 }
5835
5836
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5837 {
5838 return qe_invalid;
5839 }
5840
5841
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5842 {
5843 return qe_invalid;
5844 }
5845
5846
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5847 {
5848 return qe_invalid;
5849 }
5850
5851
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5852 {
5853 return qe_invalid;
5854 }
5855
5856
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5857 {
5858 return qe_invalid;
5859 }
5860
5861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5862 {
5863 return qe_invalid;
5864 }
5865
5866
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5867 {
5868 return qe_invalid;
5869 }
5870
5871
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5872 {
5873 return qe_invalid;
5874 }
5875
5876
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5877 {
5878 return qe_invalid;
5879 }
5880
5881
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5882 {
5883 return qe_invalid;
5884 }
5885
5886
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5887 {
5888 return qe_invalid;
5889 }
5890
5891
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5892 {
5893 return qe_invalid;
5894 }
5895
5896
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5897 {
5898 return qe_invalid;
5899 }
5900
5901 3 temp_misc.colors.msgtext = 0x01;
5902
5903
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version < 0x193)
5904 {
5905 for(int32_t i=0; i<7; i++)
5906 {
5907 if(!p_getc(&tempbyte,f,true))
5908 {
5909 return qe_invalid;
5910 }
5911 }
5912 }
5913
5914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>145))
5915 {
5916 for(int32_t i=0; i<256; i++)
5917 {
5918 if(!p_getc(&tempbyte,f,true))
5919 {
5920 return qe_invalid;
5921 }
5922 }
5923 }
5924
5925
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(s_version>1)
5926 {
5927 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5928 {
5929 return qe_invalid;
5930 }
5931 }
5932
5933 //save game icons
5934
1/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version < 0x192)||
5935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5936 {
5937 icons=3;
5938 }
5939
5940
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<icons; i++)
5941 {
5942
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_misc.icons[i],f,true))
5943 {
5944 return qe_invalid;
5945 }
5946 12 }
5947 3 }
5948
5949
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
5950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5951 {
5952 if(keepdata==true)
5953 {
5954 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5955 }
5956
5957 return 0;
5958 }
5959
5960 //pond information
5961
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
5962 {
5963 if((Header->zelda_version == 0x192)&&(Header->build<146))
5964 {
5965 pondsize=25;
5966 }
5967
5968 for(int32_t i=0; i<ponds; i++)
5969 {
5970 for(int32_t j=0; j<pondsize; j++)
5971 {
5972 if(!p_getc(&tempbyte,f,true))
5973 {
5974 return qe_invalid;
5975
5976 }
5977 }
5978 }
5979 }
5980
5981 //end string
5982
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5984 {
5985 if(!p_getc(&tempbyte,f,true))
5986 {
5987 return qe_invalid;
5988 }
5989
5990 temp_misc.endstring=tempbyte;
5991
5992 if(!p_getc(&tempbyte,f,true))
5993 {
5994 return qe_invalid;
5995 }
5996 }
5997 else
5998 {
5999
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_misc.endstring,f,true))
6000 {
6001 return qe_invalid;
6002 }
6003 }
6004
6005 //expansion
6006
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
6007 {
6008 if((Header->zelda_version == 0x192)&&(Header->build<73))
6009 {
6010 expansionsize=99*2;
6011 }
6012
6013 for(int32_t i=0; i<expansionsize; i++)
6014 {
6015 if(!p_getc(&tempbyte,f,true))
6016 {
6017 return qe_invalid;
6018 }
6019 }
6020 }
6021 //shops v8
6022
6023
6024
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 8)
6025 {
6026
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 22 times.
342 for(int32_t i=0; i<shops; i++)
6027 {
6028
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
1280 for(int32_t j=0; j<3; j++)
6029 {
6030
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6031 return qe_invalid;
6032 960 }
6033 320 }
6034 22 }
6035
6036 99 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6037 99 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6038 99 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6039
6040 //v9 includes quest misc[32]
6041
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 9)
6042 {
6043
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6044 {
6045
1/2
✓ Branch 0 taken 704 times.
✗ Branch 1 not taken.
704 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6046 return qe_invalid;
6047 704 }
6048
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6049 {
6050
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 704 times.
90816 for ( int32_t j = 0; j < 128; j++ )
6051
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6052 return qe_invalid;
6053 704 }
6054 22 }
6055
6056
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 11 )
6057 {
6058
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6059 return qe_invalid;
6060 22 }
6061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version < 11 )
6062 {
6063 77 temp_misc.zscript_last_compiled_version = -1;
6064 77 }
6065
6066 99 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6067
6068
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 12)
6069 {
6070 byte spr;
6071
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sprMAX; ++q)
6072 {
6073
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&spr,f,true))
6074 return qe_invalid;
6075 5632 temp_misc.sprites[q] = spr;
6076 5632 }
6077 22 }
6078 else
6079 {
6080 77 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6081 //temp_misc.sprites[sprFALL] = ;
6082 }
6083
6084
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 13)
6085 {
6086
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 22 times.
1430 for(size_t q = 0; q < 64; ++q)
6087 {
6088 1408 bottletype* bt = &(temp_misc.bottle_types[q]);
6089
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!pfread(bt->name, 32, f, true))
6090 return qe_invalid;
6091
2/2
✓ Branch 0 taken 4224 times.
✓ Branch 1 taken 1408 times.
5632 for(size_t j = 0; j < 3; ++j)
6092 {
6093
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_getc(&(bt->counter[j]), f, true))
6094 return qe_invalid;
6095
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_igetw(&(bt->amount[j]), f, true))
6096 return qe_invalid;
6097 4224 }
6098
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->flags), f, true))
6099 return qe_invalid;
6100
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->next_type), f, true))
6101 return qe_invalid;
6102 1408 }
6103
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(size_t q = 0; q < 256; ++q)
6104 {
6105 5632 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6106
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if (!pfread(bst->name, 32, f, true))
6107 return qe_invalid;
6108
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 5632 times.
22528 for(size_t j = 0; j < 3; ++j)
6109 {
6110
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->fill[j]), f, true))
6111 return qe_invalid;
6112
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->comb[j]), f, true))
6113 return qe_invalid;
6114
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->cset[j]), f, true))
6115 return qe_invalid;
6116
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->price[j]), f, true))
6117 return qe_invalid;
6118
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->str[j]), f, true))
6119 return qe_invalid;
6120 16896 }
6121 5632 }
6122 22 }
6123 else
6124 {
6125
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 77 times.
5005 for(size_t q = 0; q < 64; ++q)
6126 4928 temp_misc.bottle_types[q].clear();
6127
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 77 times.
19789 for(size_t q = 0; q < 256; ++q)
6128 19712 temp_misc.bottle_shop_types[q].clear();
6129 }
6130
6131
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 14)
6132 {
6133 byte msfx;
6134
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sfxMAX; ++q)
6135 {
6136
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&msfx,f,true))
6137 return qe_invalid;
6138 5632 temp_misc.miscsfx[q] = msfx;
6139 5632 }
6140 22 }
6141 else
6142 {
6143 77 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6144 77 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6145 77 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6146 }
6147
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version < 15)
6148 {
6149 77 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6150 77 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6151 77 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6152 77 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6153 77 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6154 77 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6155 77 }
6156
6157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
6158 {
6159 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6160 99 }
6161
6162 99 return 0;
6163 99 }
6164
6165 extern char *item_string[ITEMCNT];
6166 extern const char *old_item_string[iLast];
6167 extern char *weapon_string[WPNCNT];
6168 extern const char *old_weapon_string[wLast];
6169
6170 99 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6171 {
6172 byte padding;
6173 int32_t dummy;
6174 99 word items_to_read=MAXITEMS;
6175 itemdata tempitem;
6176 99 word s_version=0, s_cversion=0;
6177 word dummy_word;
6178
6179
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(version < 0x186)
6180 {
6181 items_to_read=64;
6182 }
6183
6184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
6185 {
6186 99 items_to_read=0;
6187
6188 //section version info
6189
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
6190 {
6191 return qe_invalid;
6192 }
6193
6194 99 FFCore.quest_format[vItems] = s_version;
6195
6196 //al_trace("Items version %d\n", s_version);
6197
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
6198 {
6199 return qe_invalid;
6200 }
6201
6202 //section size
6203
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
6204 {
6205 return qe_invalid;
6206 }
6207
6208 //finally... section data
6209
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&items_to_read,f,true))
6210 {
6211 return qe_invalid;
6212 }
6213 99 }
6214
6215
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>1)
6216 {
6217
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<items_to_read; i++)
6218 {
6219 char tempname[64];
6220
6221
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
6222 {
6223 return qe_invalid;
6224 }
6225
6226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
6227 {
6228 24576 strcpy(item_string[i], tempname);
6229 24576 }
6230 24576 }
6231 96 }
6232 else
6233 {
6234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
6235 {
6236
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<ITEMCNT; i++)
6237 {
6238 768 reset_itemname(i);
6239 768 }
6240 3 }
6241 }
6242
6243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
6244 {
6245
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
6246 {
6247 25344 itemdata& id = itemsbuf[i];
6248 25344 memset(&id, 0, sizeof(itemdata));
6249 25344 id.count=-1;
6250 25344 id.playsound=WAV_SCALE;
6251 25344 reset_itembuf(&id,i);
6252 25344 }
6253 99 }
6254
6255
2/2
✓ Branch 0 taken 24786 times.
✓ Branch 1 taken 99 times.
24885 for(int32_t i=0; i<items_to_read; i++)
6256 {
6257 24786 memset(&tempitem, 0, sizeof(itemdata));
6258 24786 reset_itembuf(&tempitem,i);
6259
6260
6261
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19154 times.
24786 if ( s_version > 35 ) //expanded tiles
6262 {
6263
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tile,f,true))
6264 {
6265 return qe_invalid;
6266 }
6267 5632 }
6268 else
6269 {
6270
1/2
✓ Branch 0 taken 19154 times.
✗ Branch 1 not taken.
19154 if(!p_igetw(&tempitem.tile,f,true))
6271 {
6272 return qe_invalid;
6273 }
6274 }
6275
6276
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.misc_flags,f,true))
6277 {
6278 return qe_invalid;
6279 }
6280
6281
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.csets,f,true))
6282 {
6283 return qe_invalid;
6284 }
6285
6286
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.frames,f,true))
6287 {
6288 return qe_invalid;
6289 }
6290
6291
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.speed,f,true))
6292 {
6293 return qe_invalid;
6294 }
6295
6296
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.delay,f,true))
6297 {
6298 return qe_invalid;
6299 }
6300
6301
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6302 {
6303 if(!p_getc(&padding,f,true))
6304 {
6305 return qe_invalid;
6306 }
6307
6308 if((version < 0x192)||((version == 0x192)&&(build<186)))
6309 {
6310 switch(i)
6311 {
6312 case iShield:
6313 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6314 break;
6315
6316 case iMShield:
6317 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6318 break;
6319
6320 default:
6321 tempitem.ltm=0;
6322 break;
6323 }
6324
6325 tempitem.count=-1;
6326 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6327 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6328 tempitem.family=0xFF;
6329 tempitem.playsound=WAV_SCALE;
6330 reset_itembuf(&tempitem,i);
6331
6332 if(keepdata==true)
6333 {
6334 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6335 }
6336
6337 continue;
6338 }
6339 }
6340
6341
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_igetl(&tempitem.ltm,f,true))
6342 {
6343 return qe_invalid;
6344 }
6345
6346
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6347 {
6348 for(int32_t q=0; q<12; q++)
6349 {
6350 if(!p_getc(&padding,f,true))
6351 {
6352 return qe_invalid;
6353 }
6354 }
6355 }
6356
6357
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 210 times.
24786 if(s_version>1)
6358 {
6359
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if ( s_version >= 31 )
6360 {
6361
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.family,f,true))
6362 {
6363 return qe_invalid;
6364 }
6365 5632 }
6366 else
6367 {
6368
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.family,f,true))
6369 {
6370 return qe_invalid;
6371 }
6372 }
6373
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version < 16)
6374 if(tempitem.family == 0xFF)
6375 tempitem.family = itype_misc;
6376
6377
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.fam_type,f,true))
6378 {
6379 return qe_invalid;
6380 }
6381
6382
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6383 {
6384
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version>=31)
6385 {
6386
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.power,f,true))
6387 {
6388 return qe_invalid;
6389 }
6390 5632 }
6391 else
6392 {
6393
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.power,f,true))
6394 {
6395 return qe_invalid;
6396 }
6397 }
6398
6399 //converted flags from 16b to 32b -Z
6400
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version < 41 )
6401 {
6402
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempitem.flags,f,true))
6403 {
6404 return qe_invalid;
6405 }
6406 18944 }
6407 else
6408 {
6409
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.flags,f,true))
6410 {
6411 return qe_invalid;
6412 }
6413 }
6414 24576 }
6415 else
6416 {
6417 //tempitem.power = tempitem.fam_type;
6418 char tempchar;
6419
6420 if(!p_getc(&tempchar,f,true))
6421 {
6422 return qe_invalid;
6423 }
6424
6425 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6426 }
6427
6428
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.script,f,true))
6429 {
6430 return qe_invalid;
6431 }
6432
6433
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6434 {
6435 if(tempitem.script > NUMSCRIPTITEM)
6436 {
6437 tempitem.script = 0;
6438 }
6439 }
6440
6441
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.count,f,true))
6442 {
6443 return qe_invalid;
6444 }
6445
6446
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.amount,f,true))
6447 {
6448 return qe_invalid;
6449 }
6450
6451
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.collect_script,f,true))
6452 {
6453 return qe_invalid;
6454 }
6455
6456
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6457 {
6458 if(tempitem.collect_script > NUMSCRIPTITEM)
6459 {
6460 tempitem.collect_script = 0;
6461 }
6462 }
6463
6464
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.setmax,f,true))
6465 {
6466 return qe_invalid;
6467 }
6468
6469
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.max,f,true))
6470 {
6471 return qe_invalid;
6472 }
6473
6474
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.playsound,f,true))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 24576 times.
221184 for(int32_t j=0; j<8; j++)
6480 {
6481
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&tempitem.initiald[j],f,true))
6482 {
6483 return qe_invalid;
6484 }
6485 196608 }
6486
6487
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 24576 times.
73728 for(int32_t j=0; j<2; j++)
6488 {
6489
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempitem.initiala[j],f,true))
6490 {
6491 return qe_invalid;
6492 }
6493 49152 }
6494
6495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>4)
6496 {
6497
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6498 {
6499
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn,f,true))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn2,f,true))
6505 {
6506 return qe_invalid;
6507 }
6508
6509
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn3,f,true))
6510 {
6511 return qe_invalid;
6512 }
6513
6514
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn4,f,true))
6515 {
6516 return qe_invalid;
6517 }
6518
6519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=15)
6520 {
6521
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn5,f,true))
6522 {
6523 return qe_invalid;
6524 }
6525
6526
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn6,f,true))
6527 {
6528 return qe_invalid;
6529 }
6530
6531
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn7,f,true))
6532 {
6533 return qe_invalid;
6534 }
6535
6536
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn8,f,true))
6537 {
6538 return qe_invalid;
6539 }
6540
6541
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn9,f,true))
6542 {
6543 return qe_invalid;
6544 }
6545
6546
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn10,f,true))
6547 {
6548 return qe_invalid;
6549 }
6550 24576 }
6551
6552
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.pickup_hearts,f,true))
6553 {
6554 return qe_invalid;
6555 }
6556
6557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6558 {
6559 if(!p_igetw(&dummy_word,f,true))
6560 {
6561 return qe_invalid;
6562 }
6563
6564 tempitem.misc1=dummy_word;
6565
6566 if(!p_igetw(&dummy_word,f,true))
6567 {
6568 return qe_invalid;
6569 }
6570
6571 tempitem.misc2=dummy_word;
6572 }
6573 else
6574 {
6575
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc1,f,true))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc2,f,true))
6581 {
6582 return qe_invalid;
6583 }
6584
6585 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6586
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<24)
6587 {
6588 if(tempitem.family==itype_shield)
6589 {
6590 tempitem.misc1|=shSCRIPT;
6591 }
6592 }
6593 }
6594
6595
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if(s_version < 53)
6596 {
6597 byte tempbyte;
6598
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempbyte,f,true))
6599 {
6600 return qe_invalid;
6601 }
6602 18944 tempitem.cost_amount[0] = tempbyte;
6603 18944 }
6604 else
6605 {
6606
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6607 {
6608
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6609 {
6610 return qe_invalid;
6611 }
6612 11264 }
6613 }
6614 24576 }
6615 else
6616 {
6617 char tempchar;
6618
6619 if(!p_getc(&tempchar,f,true))
6620 {
6621 return qe_invalid;
6622 }
6623
6624 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6625 }
6626
6627 // June 2007: more misc. attributes
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=12)
6629 {
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6631 {
6632 if(!p_igetw(&dummy_word,f,true))
6633 {
6634 return qe_invalid;
6635 }
6636
6637 tempitem.misc3=dummy_word;
6638
6639 if(!p_igetw(&dummy_word,f,true))
6640 {
6641 return qe_invalid;
6642 }
6643
6644 tempitem.misc4=dummy_word;
6645 }
6646 else
6647 {
6648
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc3,f,true))
6649 {
6650 return qe_invalid;
6651 }
6652
6653
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc4,f,true))
6654 {
6655 return qe_invalid;
6656 }
6657
6658
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc5,f,true))
6659 {
6660 return qe_invalid;
6661 }
6662
6663
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc6,f,true))
6664 {
6665 return qe_invalid;
6666 }
6667
6668
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc7,f,true))
6669 {
6670 return qe_invalid;
6671 }
6672
6673
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc8,f,true))
6674 {
6675 return qe_invalid;
6676 }
6677
6678
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc9,f,true))
6679 {
6680 return qe_invalid;
6681 }
6682
6683
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc10,f,true))
6684 {
6685 return qe_invalid;
6686 }
6687 }
6688
6689
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.usesound,f,true))
6690 {
6691 return qe_invalid;
6692 }
6693
6694
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version >= 49)
6695 {
6696
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usesound2,f,true))
6697 {
6698 return qe_invalid;
6699 }
6700 5632 }
6701 18944 else tempitem.usesound2 = 0;
6702
6703
3/4
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
24576 if(s_version < 50 && tempitem.family == itype_mirror)
6704 {
6705 //Split continue/dmap warp effect/sfx, port for old
6706 tempitem.misc2 = tempitem.misc1;
6707 tempitem.usesound2 = tempitem.usesound;
6708 }
6709 24576 }
6710 24576 }
6711
6712
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6713 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6714
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.useweapon,f,true))
6715 {
6716 return qe_invalid;
6717 }
6718
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usedefence,f,true))
6719 {
6720 return qe_invalid;
6721 }
6722
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weaprange,f,true))
6723 {
6724 return qe_invalid;
6725 }
6726
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapduration,f,true))
6727 {
6728 return qe_invalid;
6729 }
6730
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 5632 times.
61952 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6731 {
6732
1/2
✓ Branch 0 taken 56320 times.
✗ Branch 1 not taken.
56320 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6733 {
6734 return qe_invalid;
6735 }
6736 56320 }
6737 5632 }
6738
6739
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6740 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6741
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.duplicates,f,true))
6742 {
6743 return qe_invalid;
6744 }
6745
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < INITIAL_D; q++ )
6746 {
6747
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6748 {
6749 return qe_invalid;
6750 }
6751 45056 }
6752
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < INITIAL_A; q++ )
6753 {
6754
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6755 {
6756 return qe_invalid;
6757 }
6758 11264 }
6759
6760
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.drawlayer,f,true))
6761 {
6762 return qe_invalid;
6763 }
6764
6765
6766
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxofs,f,true))
6767 {
6768 return qe_invalid;
6769 }
6770
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hyofs,f,true))
6771 {
6772 return qe_invalid;
6773 }
6774
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxsz,f,true))
6775 {
6776 return qe_invalid;
6777 }
6778
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hysz,f,true))
6779 {
6780 return qe_invalid;
6781 }
6782
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hzsz,f,true))
6783 {
6784 return qe_invalid;
6785 }
6786
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.xofs,f,true))
6787 {
6788 return qe_invalid;
6789 }
6790
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.yofs,f,true))
6791 {
6792 return qe_invalid;
6793 }
6794
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6795 {
6796 return qe_invalid;
6797 }
6798
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6799 {
6800 return qe_invalid;
6801 }
6802
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6803 {
6804 return qe_invalid;
6805 }
6806
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hysz,f,true))
6807 {
6808 return qe_invalid;
6809 }
6810
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6811 {
6812 return qe_invalid;
6813 }
6814
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_xofs,f,true))
6815 {
6816 return qe_invalid;
6817 }
6818
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_yofs,f,true))
6819 {
6820 return qe_invalid;
6821 }
6822
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.weaponscript,f,true))
6823 {
6824 return qe_invalid;
6825 }
6826
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.wpnsprite,f,true))
6827 {
6828 return qe_invalid;
6829 }
6830 5632 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6831
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < num_cost_tmr; ++q)
6832 {
6833
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6834 {
6835 return qe_invalid;
6836 }
6837 11264 }
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 for(auto q = num_cost_tmr; q < 2; ++q)
6839 tempitem.magiccosttimer[q] = 0;
6840 5632 }
6841
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6842 {
6843 //Item Size FLags, TileWidth, TileHeight
6844
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6845 {
6846 return qe_invalid;
6847 }
6848
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tilew,f,true))
6849 {
6850 return qe_invalid;
6851 }
6852
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tileh,f,true))
6853 {
6854 return qe_invalid;
6855 }
6856 5632 }
6857
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 29 ) //! More new vars.
6858 {
6859 //Item Size FLags, TileWidth, TileHeight
6860
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6861 {
6862 return qe_invalid;
6863 }
6864
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tilew,f,true))
6865 {
6866 return qe_invalid;
6867 }
6868
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tileh,f,true))
6869 {
6870 return qe_invalid;
6871 }
6872 5632 }
6873
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 30 ) //! More new vars.
6874 {
6875 //Pickup Type
6876
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.pickup,f,true))
6877 {
6878 return qe_invalid;
6879 }
6880 5632 }
6881
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 32 ) //! More new vars.
6882 {
6883 //Pickup Type
6884
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pstring,f,true))
6885 {
6886 return qe_invalid;
6887 }
6888 5632 }
6889
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 33 ) //! More new vars.
6890 {
6891 //Pickup Type
6892
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6893 {
6894 return qe_invalid;
6895 }
6896 5632 }
6897
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 34 ) //! cost counter
6898 {
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 if(s_version < 53)
6900 {
6901 if(!p_getc(&tempitem.cost_counter[0],f,true))
6902 {
6903 return qe_invalid;
6904 }
6905 }
6906 else
6907 {
6908
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6909 {
6910
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.cost_counter[q],f,true))
6911 {
6912 return qe_invalid;
6913 }
6914 11264 }
6915 }
6916 5632 }
6917
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 44 ) //! sprite scripts
6918 {
6919
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
6920 {
6921
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6922 {
6923
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6924 {
6925 return qe_invalid;
6926 }
6927 2928640 }
6928
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6929 {
6930
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6931 {
6932 return qe_invalid;
6933 }
6934 2928640 }
6935
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6936 {
6937
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6938 {
6939 return qe_invalid;
6940 }
6941 2928640 }
6942
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6943 {
6944 return qe_invalid;
6945 }
6946
6947 45056 }
6948
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < 2; q++ )
6949 {
6950
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6951 {
6952 return qe_invalid;
6953 }
6954 11264 }
6955 //Pickup Type
6956
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.sprite_script,f,true))
6957 {
6958 return qe_invalid;
6959 }
6960 5632 }
6961
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 48 ) //! pickup flags
6962 {
6963
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
6964 {
6965 return qe_invalid;
6966 }
6967 5632 }
6968 24576 }
6969 else
6970 {
6971 210 tempitem.count=-1;
6972 210 tempitem.family=itype_misc;
6973 210 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6974 210 tempitem.playsound=WAV_SCALE;
6975 210 reset_itembuf(&tempitem,i);
6976 }
6977
6978
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(keepdata==true)
6979 {
6980 24786 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6981 24786 }
6982 else if(zgpmode)
6983 {
6984 itemsbuf[i].tile=tempitem.tile;
6985 itemsbuf[i].misc_flags=tempitem.misc_flags;
6986 itemsbuf[i].csets=tempitem.csets;
6987 itemsbuf[i].frames=tempitem.frames;
6988 itemsbuf[i].speed=tempitem.speed;
6989 itemsbuf[i].delay=tempitem.delay;
6990 itemsbuf[i].ltm=tempitem.ltm;
6991 }
6992 24786 }
6993
6994 //////////////////////////////////////////////////////
6995 // Now do any updates because of new item additions
6996 // (These can't be done above because items_to_read
6997 // might be too low.)
6998 //////////////////////////////////////////////////////
6999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
7000 {
7001
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
7002 {
7003 25344 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7004
7005 //Account for older quests that didn't have an actual item for the used letter
7006
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 2 && i==iLetterUsed)
7007 {
7008 3 reset_itembuf(&tempitem, iLetterUsed);
7009 3 strcpy(item_string[i],old_item_string[i]);
7010 3 tempitem.tile = itemsbuf[iLetter].tile;
7011 3 tempitem.csets = itemsbuf[iLetter].csets;
7012 3 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7013 3 tempitem.frames = itemsbuf[iLetter].frames;
7014 3 tempitem.speed = itemsbuf[iLetter].speed;
7015 3 tempitem.ltm = itemsbuf[iLetter].ltm;
7016 3 }
7017
7018
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 3)
7019 {
7020
3/3
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 699 times.
✓ Branch 2 taken 3 times.
768 switch(i)
7021 {
7022 case iRocsFeather:
7023 case iHoverBoots:
7024 case iSpinScroll:
7025 case iL2SpinScroll:
7026 case iCrossScroll:
7027 case iQuakeScroll:
7028 case iL2QuakeScroll:
7029 case iWhispRing:
7030 case iL2WhispRing:
7031 case iChargeRing:
7032 case iL2ChargeRing:
7033 case iPerilScroll:
7034 case iWalletL3:
7035 case iQuiverL4:
7036 case iBombBagL4:
7037 case iBracelet:
7038 case iL2Bracelet:
7039 case iOldGlove:
7040 case iL2Ladder:
7041 case iWealthMedal:
7042 case iL2WealthMedal:
7043 case iL3WealthMedal:
7044 66 reset_itembuf(&tempitem, i);
7045 66 strcpy(item_string[i],old_item_string[i]);
7046 66 break;
7047
7048 case iSShield:
7049 3 reset_itembuf(&tempitem, i);
7050 3 strcpy(item_string[i],old_item_string[i]);
7051 3 strcpy(item_string[iShield],old_item_string[iShield]);
7052 3 strcpy(item_string[iMShield],old_item_string[iMShield]);
7053 3 break;
7054 }
7055 768 }
7056
7057
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 5)
7058 {
7059
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 747 times.
768 switch(i)
7060 {
7061 case iHeartRing:
7062 case iL2HeartRing:
7063 case iL3HeartRing:
7064 case iMagicRing:
7065 case iL2MagicRing:
7066 case iL3MagicRing:
7067 case iL4MagicRing:
7068 21 reset_itembuf(&tempitem, i);
7069 21 strcpy(item_string[i],old_item_string[i]);
7070 21 break;
7071 }
7072 768 }
7073
7074
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7075 {
7076
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(i!=iBPotion && i!=iRPotion)
7077 762 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7078
7079
43/43
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 3 times.
✓ Branch 27 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 3 times.
✓ Branch 30 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 3 times.
✓ Branch 34 taken 3 times.
✓ Branch 35 taken 3 times.
✓ Branch 36 taken 3 times.
✓ Branch 37 taken 3 times.
✓ Branch 38 taken 3 times.
✓ Branch 39 taken 3 times.
✓ Branch 40 taken 3 times.
✓ Branch 41 taken 3 times.
✓ Branch 42 taken 3 times.
768 switch(i)
7080 {
7081 case iTriforce:
7082 3 tempitem.fam_type=1;
7083 3 break;
7084
7085 case iBigTri:
7086 3 tempitem.fam_type=0;
7087 3 break;
7088
7089 case iBombs:
7090 3 tempitem.fam_type=i_bomb;
7091 3 tempitem.power=4;
7092 3 tempitem.wpn=wBOMB;
7093 3 tempitem.wpn2=wBOOM;
7094 3 tempitem.misc1 = 50;
7095
7096
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7097
7098 3 break;
7099
7100 case iSBomb:
7101 3 tempitem.fam_type=i_sbomb;
7102 3 tempitem.power=16;
7103 3 tempitem.wpn=wSBOMB;
7104 3 tempitem.wpn2=wSBOOM;
7105 3 tempitem.misc1 = 50;
7106
7107
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7108
7109 3 break;
7110
7111 case iBook:
7112
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, 113))
7113 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7114
7115 3 break;
7116
7117 case iSArrow:
7118 3 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7119 3 tempitem.power=4;
7120 3 tempitem.flags|=ITEM_GAMEDATA;
7121 3 tempitem.wpn=wSARROW;
7122 3 break;
7123
7124 case iGArrow:
7125 3 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7126 3 tempitem.power=8;
7127 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7128 3 tempitem.wpn=wGARROW;
7129 3 break;
7130
7131 case iBrang:
7132 3 tempitem.power=0;
7133 3 tempitem.wpn=wBRANG;
7134 3 tempitem.misc1=36;
7135 3 break;
7136
7137 case iMBrang:
7138 3 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7139 3 tempitem.power=0;
7140 3 tempitem.wpn=wMBRANG;
7141 3 break;
7142
7143 case iFBrang:
7144 3 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7145 3 tempitem.power=2;
7146 3 tempitem.wpn=wFBRANG;
7147 3 break;
7148
7149 case iBoots:
7150 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7151 3 tempitem.power=7;
7152 3 break;
7153
7154 case iWand:
7155 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7156 3 tempitem.power=2;
7157 3 tempitem.wpn=wWAND;
7158 3 tempitem.wpn3=wMAGIC;
7159 3 break;
7160
7161 case iBCandle:
7162 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7163 3 tempitem.power=1;
7164 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7165 3 tempitem.wpn3=wFIRE;
7166 3 break;
7167
7168 case iRCandle:
7169 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7170 3 tempitem.power=1;
7171 3 tempitem.wpn3=wFIRE;
7172 3 break;
7173
7174 case iSword:
7175 3 tempitem.power=1;
7176 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7177 3 tempitem.wpn=tempitem.wpn3=wSWORD;
7178 3 tempitem.wpn2=wSWORDSLASH;
7179 3 break;
7180
7181 case iWSword:
7182 3 tempitem.power=2;
7183 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7184 3 tempitem.wpn=tempitem.wpn3=wWSWORD;
7185 3 tempitem.wpn2=wWSWORDSLASH;
7186 3 break;
7187
7188 case iMSword:
7189 3 tempitem.power=4;
7190 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7191 3 tempitem.wpn=tempitem.wpn3=wMSWORD;
7192 3 tempitem.wpn2=wMSWORDSLASH;
7193 3 break;
7194
7195 case iXSword:
7196 3 tempitem.power=8;
7197 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7198 3 tempitem.wpn=tempitem.wpn3=wXSWORD;
7199 3 tempitem.wpn2=wXSWORDSLASH;
7200 3 break;
7201
7202 case iDivineProtection:
7203 3 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7204 3 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7205 3 tempitem.wpn=wDIVINEPROTECTION1A;
7206 3 tempitem.wpn2=wDIVINEPROTECTION1B;
7207 3 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7208 3 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7209 3 tempitem.wpn6=wDIVINEPROTECTION2A;
7210 3 tempitem.wpn7=wDIVINEPROTECTION2B;
7211 3 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7212 3 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7213 3 tempitem.wpn5 = iwDivineProtectionShieldFront;
7214 3 tempitem.wpn10 = iwDivineProtectionShieldBack;
7215 3 tempitem.misc1=512;
7216 3 tempitem.cost_amount[0]=64;
7217 3 break;
7218
7219 case iLens:
7220 3 tempitem.misc1=60;
7221 3 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7222 3 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7223 3 break;
7224
7225 case iArrow:
7226 3 tempitem.power=2;
7227 3 tempitem.wpn=wARROW;
7228 3 break;
7229
7230 case iHoverBoots:
7231 3 tempitem.misc1=45;
7232 3 tempitem.wpn=iwHover;
7233 3 break;
7234
7235 case iDivineFire:
7236 3 tempitem.power=8;
7237 3 tempitem.wpn=wDIVINEFIRE1A;
7238 3 tempitem.wpn2=wDIVINEFIRE1B;
7239 3 tempitem.wpn3=wDIVINEFIRES1A;
7240 3 tempitem.wpn4=wDIVINEFIRES1B;
7241 3 tempitem.misc1 = 32;
7242 3 tempitem.misc2 = 200;
7243 3 tempitem.cost_amount[0]=32;
7244 3 break;
7245
7246 case iDivineEscape:
7247 3 tempitem.cost_amount[0]=32;
7248 3 break;
7249
7250 case iHookshot:
7251 3 tempitem.power=0;
7252 3 tempitem.flags&=~ITEM_FLAG1;
7253 3 tempitem.wpn=wHSHEAD;
7254 3 tempitem.wpn2=wHSCHAIN_H;
7255 3 tempitem.wpn4=wHSHANDLE;
7256 3 tempitem.wpn3=wHSCHAIN_V;
7257 3 tempitem.misc1=50;
7258 3 tempitem.misc2=100;
7259 3 break;
7260
7261 case iLongshot:
7262 3 tempitem.power=0;
7263 3 tempitem.flags&=~ITEM_FLAG1;
7264 3 tempitem.wpn=wLSHEAD;
7265 3 tempitem.wpn2=wLSCHAIN_H;
7266 3 tempitem.wpn4=wLSHANDLE;
7267 3 tempitem.wpn3=wLSCHAIN_V;
7268 3 tempitem.misc1=99;
7269 3 tempitem.misc2=100;
7270 3 break;
7271
7272 case iHammer:
7273 3 tempitem.power=4;
7274 3 tempitem.wpn=wHAMMER;
7275 3 tempitem.wpn2=iwHammerSmack;
7276 3 break;
7277
7278 case iCByrna:
7279 3 tempitem.power=1;
7280 3 tempitem.wpn=wCBYRNA;
7281 3 tempitem.wpn2=wCBYRNASLASH;
7282 3 tempitem.wpn3=wCBYRNAORB;
7283 3 tempitem.misc1=4;
7284 3 tempitem.misc2=16;
7285 3 tempitem.misc3=1;
7286 3 tempitem.cost_amount[0]=1;
7287 3 break;
7288
7289 case iWhistle:
7290 3 tempitem.wpn=wWIND;
7291 3 tempitem.misc1=3;
7292 3 tempitem.flags|=ITEM_FLAG1;
7293 3 break;
7294
7295 case iBRing:
7296 3 tempitem.power=2;
7297 3 tempitem.misc1=spBLUE;
7298 3 break;
7299
7300 case iRRing:
7301 3 tempitem.power=4;
7302 3 tempitem.misc1=spRED;
7303 3 break;
7304
7305 case iGRing:
7306 3 tempitem.power=8;
7307 3 tempitem.misc1=spGOLD;
7308 3 break;
7309
7310 case iSpinScroll:
7311 3 tempitem.power = 2;
7312 3 tempitem.misc1 = 1;
7313 3 break;
7314
7315 case iL2SpinScroll:
7316 3 tempitem.family=itype_spinscroll2;
7317 3 tempitem.fam_type=1;
7318 3 tempitem.cost_amount[0]=8;
7319 3 tempitem.power=2;
7320 3 tempitem.misc1 = 20;
7321 3 break;
7322
7323 case iQuakeScroll:
7324 3 tempitem.misc1=0x10;
7325 3 tempitem.misc2=64;
7326 3 break;
7327
7328 case iL2QuakeScroll:
7329 3 tempitem.family=itype_quakescroll2;
7330 3 tempitem.fam_type=1;
7331 3 tempitem.power = 2;
7332 3 tempitem.misc1=0x20;
7333 3 tempitem.misc2=192;
7334 3 tempitem.cost_amount[0]=8;
7335 3 break;
7336
7337 case iChargeRing:
7338 3 tempitem.misc1=64;
7339 3 tempitem.misc2=128;
7340 3 break;
7341
7342 case iL2ChargeRing:
7343 3 tempitem.misc1=32;
7344 3 tempitem.misc2=64;
7345 3 break;
7346
7347 case iOldGlove:
7348 3 tempitem.flags |= ITEM_FLAG1;
7349
7350 //fallthrough
7351 case iBombBagL4:
7352 case iWalletL3:
7353 case iQuiverL4:
7354 case iBracelet:
7355 15 tempitem.power = 1;
7356 15 break;
7357
7358 case iL2Bracelet:
7359 3 tempitem.power = 2;
7360 3 break;
7361
7362 case iMKey:
7363 3 tempitem.power=0xFF;
7364 3 tempitem.flags |= ITEM_FLAG1;
7365 3 break;
7366 }
7367 768 }
7368
7369
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 7)
7370 {
7371
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 756 times.
768 switch(i)
7372 {
7373 case iStoneAgony:
7374 case iStompBoots:
7375 case iPerilRing:
7376 case iWhimsicalRing:
7377 {
7378 12 reset_itembuf(&tempitem, i);
7379 12 strcpy(item_string[i],old_item_string[i]);
7380 12 break;
7381 }
7382 }
7383 768 }
7384
7385
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 8) // May 2007: Some corrections.
7386 {
7387
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 744 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
768 switch(i)
7388 {
7389 case iMShield:
7390 3 tempitem.misc1|=shFLAME;
7391 3 tempitem.misc2|=shFIREBALL|shMAGIC;
7392
7393
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules, qr_SWORDMIRROR))
7394 {
7395 tempitem.misc2 |= shSWORD;
7396 }
7397
7398 // fallthrough
7399 case iShield:
7400 6 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7401
7402 // fallthrough
7403 case iSShield:
7404 9 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7405
7406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7407 {
7408 tempitem.misc2 |= shROCK;
7409 }
7410
7411 9 break;
7412
7413 case iWhispRing:
7414 3 tempitem.power=1;
7415 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7416 3 tempitem.misc1 = 3;
7417 3 break;
7418
7419 case iL2WhispRing:
7420 3 tempitem.power=0;
7421 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7422 3 tempitem.misc1 = 3;
7423 3 break;
7424
7425 case iL2Ladder:
7426 case iBow:
7427 case iCByrna:
7428 9 tempitem.power = 1;
7429 9 break;
7430 }
7431 768 }
7432
7433
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 9 && i==iClock)
7434 {
7435 3 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7436 3 }
7437
7438 //add the misc flag for bomb
7439
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 10 && tempitem.family == itype_bomb)
7440 {
7441 3 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7442 3 }
7443
7444
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 6 times.
25344 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7445 {
7446 6 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7447 6 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7448 6 }
7449
7450
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 12) // June 2007: More Misc. attributes.
7451 {
7452
5/5
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
768 switch(i)
7453 {
7454 case iFBrang:
7455 3 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7456
7457 //fallthrough
7458 case iMBrang:
7459 6 tempitem.misc3 |= shSWORD|shMAGIC;
7460
7461 //fallthrough
7462 case iHookshot:
7463 case iLongshot:
7464 //fallthrough
7465 12 tempitem.misc3 |= shFIREBALL;
7466
7467 case iBrang:
7468 15 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7469 15 break;
7470 }
7471
7472
16/16
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 411 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
768 switch(tempitem.family)
7473 {
7474 case itype_hoverboots:
7475 3 tempitem.usesound = WAV_ZN1HOVER;
7476 3 break;
7477
7478 case itype_wand:
7479 3 tempitem.usesound = WAV_WAND;
7480 3 break;
7481
7482 case itype_book:
7483 3 tempitem.usesound = WAV_FIRE;
7484 3 break;
7485
7486 case itype_arrow:
7487 9 tempitem.usesound = WAV_ARROW;
7488 9 break;
7489
7490 case itype_hookshot:
7491 6 tempitem.usesound = WAV_HOOKSHOT;
7492 6 break;
7493
7494 case itype_brang:
7495 9 tempitem.usesound = WAV_BRANG;
7496 9 break;
7497
7498 case itype_shield:
7499 9 tempitem.usesound = WAV_CHINK;
7500 9 break;
7501
7502 case itype_sword:
7503 411 tempitem.usesound = WAV_SWORD;
7504 411 break;
7505
7506 case itype_whistle:
7507 3 tempitem.usesound = WAV_WHISTLE;
7508 3 break;
7509
7510 case itype_hammer:
7511 3 tempitem.usesound = WAV_HAMMER;
7512 3 break;
7513
7514 case itype_divinefire:
7515 3 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7516 3 break;
7517
7518 case itype_divineescape:
7519 3 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7520 3 break;
7521
7522 case itype_divineprotection:
7523 3 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7524 3 break;
7525
7526 case itype_bomb:
7527 case itype_sbomb:
7528 case itype_quakescroll:
7529 case itype_quakescroll2:
7530 12 tempitem.usesound = WAV_BOMB;
7531 12 break;
7532
7533 case itype_spinscroll:
7534 case itype_spinscroll2:
7535 6 tempitem.usesound = WAV_ZN1SPINATTACK;
7536 6 break;
7537 }
7538 768 }
7539
7540
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 13) // July 2007
7541 {
7542
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7543 {
7544 3 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7545 3 tempitem.power = 1;
7546 3 tempitem.flags|=ITEM_FLAG1;
7547 3 }
7548
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_wand)
7549 3 tempitem.flags|=ITEM_FLAG1;
7550
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 3 times.
762 else if(tempitem.family == itype_book)
7551 {
7552 3 tempitem.flags|=ITEM_FLAG1;
7553 3 tempitem.power = 2;
7554 3 }
7555 768 }
7556
7557
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 14) // August 2007
7558 {
7559
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
768 if(tempitem.family == itype_fairy)
7560 {
7561 6 tempitem.usesound = WAV_SCALE;
7562
7563
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tempitem.fam_type)
7564 6 tempitem.misc3=50;
7565 6 }
7566
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_potion)
7567 {
7568 6 tempitem.flags |= ITEM_GAINOLD;
7569 6 }
7570 768 }
7571
7572
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 17) // November 2007
7573 {
7574
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
768 if(tempitem.family == itype_candle && !tempitem.wpn3)
7575 {
7576 tempitem.wpn3 = wFIRE;
7577 }
7578
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 759 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 3 times.
768 else if(tempitem.family == itype_arrow && tempitem.power>4)
7579 {
7580 3 tempitem.flags|=ITEM_FLAG1;
7581 3 }
7582 768 }
7583
7584
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 18) // New Year's Eve 2007
7585 {
7586
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7587 3 tempitem.misc2 = 8; // Use the Whistle warp ring
7588
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_bait)
7589 3 tempitem.misc1 = 768; // Frames until it goes
7590
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_triforcepiece)
7591 {
7592
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(tempitem.flags & ITEM_GAMEDATA)
7593 {
7594 3 tempitem.misc2 = 1; // Cutscene 1
7595 3 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7596 3 }
7597 6 }
7598 768 }
7599
7600
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 19) // January 2008
7601 {
7602
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_divineprotection)
7603 {
7604 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7605 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7606 3 }
7607 768 }
7608
7609
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 20) // October 2008
7610 {
7611
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_divineprotection)
7612 {
7613 3 tempitem.wpn6=wDIVINEPROTECTION2A;
7614 3 tempitem.wpn7=wDIVINEPROTECTION2B;
7615 3 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7616 3 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7617 3 tempitem.wpn5 = iwDivineProtectionShieldFront;
7618 3 tempitem.wpn10 = iwDivineProtectionShieldBack;
7619 3 }
7620 768 }
7621
7622
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 21) // November 2008
7623 {
7624
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(tempitem.flags & 0x0100) // ITEM_SLASH
7625 {
7626 tempitem.flags &= ~0x0100;
7627
7628 if(tempitem.family == itype_sword ||
7629 tempitem.family == itype_wand ||
7630 tempitem.family == itype_candle ||
7631 tempitem.family == itype_cbyrna)
7632 {
7633 tempitem.flags |= ITEM_FLAG4;
7634 }
7635 }
7636 768 }
7637
7638
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 22) // September 2009
7639 {
7640
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7641 {
7642 6 tempitem.misc3 = tempitem.power/2;
7643 6 }
7644 768 }
7645
7646
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 23) // March 2011
7647 {
7648
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_divinefire)
7649 3 tempitem.wpn5 = wFIRE;
7650
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 3 times.
765 else if(tempitem.family == itype_book)
7651 3 tempitem.wpn2 = wFIRE;
7652 768 }
7653
7654 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7655 // whether it was or not, and a lot of existing quests depended on the
7656 // incorrect behavior.
7657
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 25) // January 2012
7658 {
7659
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 12 times.
768 if(tempitem.family == itype_bombbag)
7660 12 tempitem.flags |= 16;
7661
7662
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_divinefire)
7663 3 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7664 768 }
7665
7666
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7667 {
7668
60/60
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 827 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 970 times.
✓ Branch 4 taken 2157 times.
✓ Branch 5 taken 6474 times.
✓ Branch 6 taken 231 times.
✓ Branch 7 taken 229 times.
✓ Branch 8 taken 192 times.
✓ Branch 9 taken 123 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 154 times.
✓ Branch 12 taken 153 times.
✓ Branch 13 taken 92 times.
✓ Branch 14 taken 231 times.
✓ Branch 15 taken 231 times.
✓ Branch 16 taken 152 times.
✓ Branch 17 taken 231 times.
✓ Branch 18 taken 154 times.
✓ Branch 19 taken 77 times.
✓ Branch 20 taken 154 times.
✓ Branch 21 taken 92 times.
✓ Branch 22 taken 77 times.
✓ Branch 23 taken 231 times.
✓ Branch 24 taken 77 times.
✓ Branch 25 taken 77 times.
✓ Branch 26 taken 154 times.
✓ Branch 27 taken 77 times.
✓ Branch 28 taken 77 times.
✓ Branch 29 taken 77 times.
✓ Branch 30 taken 77 times.
✓ Branch 31 taken 77 times.
✓ Branch 32 taken 92 times.
✓ Branch 33 taken 77 times.
✓ Branch 34 taken 77 times.
✓ Branch 35 taken 77 times.
✓ Branch 36 taken 77 times.
✓ Branch 37 taken 154 times.
✓ Branch 38 taken 308 times.
✓ Branch 39 taken 77 times.
✓ Branch 40 taken 77 times.
✓ Branch 41 taken 136 times.
✓ Branch 42 taken 308 times.
✓ Branch 43 taken 77 times.
✓ Branch 44 taken 77 times.
✓ Branch 45 taken 77 times.
✓ Branch 46 taken 77 times.
✓ Branch 47 taken 77 times.
✓ Branch 48 taken 154 times.
✓ Branch 49 taken 154 times.
✓ Branch 50 taken 77 times.
✓ Branch 51 taken 231 times.
✓ Branch 52 taken 231 times.
✓ Branch 53 taken 308 times.
✓ Branch 54 taken 77 times.
✓ Branch 55 taken 77 times.
✓ Branch 56 taken 77 times.
✓ Branch 57 taken 77 times.
✓ Branch 58 taken 77 times.
✓ Branch 59 taken 77 times.
19712 switch(tempitem.family)
7669 {
7670 case itype_sword:
7671 {
7672 6474 tempitem.flags &= ~(ITEM_FLAG5);
7673 6474 tempitem.misc3 = 0;
7674 6474 tempitem.misc4 = 0;
7675 6474 tempitem.misc5 = 0;
7676 6474 tempitem.misc6 = 0;
7677 6474 tempitem.misc7 = 0;
7678 6474 tempitem.misc8 = 0;
7679 6474 tempitem.misc9 = 0;
7680 6474 tempitem.misc10 = 0;
7681 6474 tempitem.wpn4 = 0;
7682 6474 tempitem.wpn5 = 0;
7683 6474 tempitem.wpn6 = 0;
7684 6474 tempitem.wpn7 = 0;
7685 6474 tempitem.wpn8 = 0;
7686 6474 tempitem.wpn9 = 0;
7687 6474 tempitem.wpn10 = 0;
7688 6474 break;
7689 }
7690 case itype_brang:
7691 {
7692 231 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7693 231 tempitem.misc2 = 0;
7694 231 tempitem.misc5 = 0;
7695 231 tempitem.misc6 = 0;
7696 231 tempitem.misc7 = 0;
7697 231 tempitem.misc8 = 0;
7698 231 tempitem.misc9 = 0;
7699 231 tempitem.misc10 = 0;
7700 231 tempitem.wpn4 = 0;
7701 231 tempitem.wpn5 = 0;
7702 231 tempitem.wpn6 = 0;
7703 231 tempitem.wpn7 = 0;
7704 231 tempitem.wpn8 = 0;
7705 231 tempitem.wpn9 = 0;
7706 231 tempitem.wpn10 = 0;
7707 231 break;
7708 }
7709 case itype_arrow:
7710 {
7711 229 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7712 229 tempitem.misc2 = 0;
7713 229 tempitem.misc3 = 0;
7714 229 tempitem.misc4 = 0;
7715 229 tempitem.misc5 = 0;
7716 229 tempitem.misc6 = 0;
7717 229 tempitem.misc7 = 0;
7718 229 tempitem.misc8 = 0;
7719 229 tempitem.misc9 = 0;
7720 229 tempitem.misc10 = 0;
7721 229 tempitem.wpn4 = 0;
7722 229 tempitem.wpn5 = 0;
7723 229 tempitem.wpn6 = 0;
7724 229 tempitem.wpn7 = 0;
7725 229 tempitem.wpn8 = 0;
7726 229 tempitem.wpn9 = 0;
7727 229 tempitem.wpn10 = 0;
7728 229 break;
7729 }
7730 case itype_candle:
7731 {
7732 192 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7733 192 tempitem.misc1 = 0;
7734 192 tempitem.misc2 = 0;
7735 192 tempitem.misc3 = 0;
7736 192 tempitem.misc4 = 0;
7737 192 tempitem.misc5 = 0;
7738 192 tempitem.misc6 = 0;
7739 192 tempitem.misc7 = 0;
7740 192 tempitem.misc8 = 0;
7741 192 tempitem.misc9 = 0;
7742 192 tempitem.misc10 = 0;
7743 192 tempitem.wpn4 = 0;
7744 192 tempitem.wpn5 = 0;
7745 192 tempitem.wpn6 = 0;
7746 192 tempitem.wpn7 = 0;
7747 192 tempitem.wpn8 = 0;
7748 192 tempitem.wpn9 = 0;
7749 192 tempitem.wpn10 = 0;
7750 192 break;
7751 }
7752 case itype_whistle:
7753 {
7754 123 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7755 123 tempitem.misc3 = 0;
7756 123 tempitem.misc4 = 0;
7757 123 tempitem.misc5 = 0;
7758 123 tempitem.misc6 = 0;
7759 123 tempitem.misc7 = 0;
7760 123 tempitem.misc8 = 0;
7761 123 tempitem.misc9 = 0;
7762 123 tempitem.misc10 = 0;
7763 123 tempitem.wpn2 = 0;
7764 123 tempitem.wpn3 = 0;
7765 123 tempitem.wpn4 = 0;
7766 123 tempitem.wpn5 = 0;
7767 123 tempitem.wpn6 = 0;
7768 123 tempitem.wpn7 = 0;
7769 123 tempitem.wpn8 = 0;
7770 123 tempitem.wpn9 = 0;
7771 123 tempitem.wpn10 = 0;
7772 123 break;
7773 }
7774 case itype_bait:
7775 {
7776 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7777 77 tempitem.misc2 = 0;
7778 77 tempitem.misc3 = 0;
7779 77 tempitem.misc4 = 0;
7780 77 tempitem.misc5 = 0;
7781 77 tempitem.misc6 = 0;
7782 77 tempitem.misc7 = 0;
7783 77 tempitem.misc8 = 0;
7784 77 tempitem.misc9 = 0;
7785 77 tempitem.misc10 = 0;
7786 77 tempitem.wpn2 = 0;
7787 77 tempitem.wpn3 = 0;
7788 77 tempitem.wpn4 = 0;
7789 77 tempitem.wpn5 = 0;
7790 77 tempitem.wpn6 = 0;
7791 77 tempitem.wpn7 = 0;
7792 77 tempitem.wpn8 = 0;
7793 77 tempitem.wpn9 = 0;
7794 77 tempitem.wpn10 = 0;
7795 77 break;
7796 }
7797 case itype_letter:
7798 {
7799 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7800 154 tempitem.misc1 = 0;
7801 154 tempitem.misc2 = 0;
7802 154 tempitem.misc3 = 0;
7803 154 tempitem.misc4 = 0;
7804 154 tempitem.misc5 = 0;
7805 154 tempitem.misc6 = 0;
7806 154 tempitem.misc7 = 0;
7807 154 tempitem.misc8 = 0;
7808 154 tempitem.misc9 = 0;
7809 154 tempitem.misc10 = 0;
7810 154 tempitem.wpn = 0;
7811 154 tempitem.wpn2 = 0;
7812 154 tempitem.wpn3 = 0;
7813 154 tempitem.wpn4 = 0;
7814 154 tempitem.wpn5 = 0;
7815 154 tempitem.wpn6 = 0;
7816 154 tempitem.wpn7 = 0;
7817 154 tempitem.wpn8 = 0;
7818 154 tempitem.wpn9 = 0;
7819 154 tempitem.wpn10 = 0;
7820 154 break;
7821 }
7822 case itype_potion:
7823 {
7824 153 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7825 153 tempitem.misc3 = 0;
7826 153 tempitem.misc4 = 0;
7827 153 tempitem.misc5 = 0;
7828 153 tempitem.misc6 = 0;
7829 153 tempitem.misc7 = 0;
7830 153 tempitem.misc8 = 0;
7831 153 tempitem.misc9 = 0;
7832 153 tempitem.misc10 = 0;
7833 153 tempitem.wpn = 0;
7834 153 tempitem.wpn2 = 0;
7835 153 tempitem.wpn3 = 0;
7836 153 tempitem.wpn4 = 0;
7837 153 tempitem.wpn5 = 0;
7838 153 tempitem.wpn6 = 0;
7839 153 tempitem.wpn7 = 0;
7840 153 tempitem.wpn8 = 0;
7841 153 tempitem.wpn9 = 0;
7842 153 tempitem.wpn10 = 0;
7843 153 break;
7844 }
7845 case itype_wand:
7846 {
7847 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7848 92 tempitem.misc1 = 0;
7849 92 tempitem.misc2 = 0;
7850 92 tempitem.misc3 = 0;
7851 92 tempitem.misc4 = 0;
7852 92 tempitem.misc5 = 0;
7853 92 tempitem.misc6 = 0;
7854 92 tempitem.misc7 = 0;
7855 92 tempitem.misc8 = 0;
7856 92 tempitem.misc9 = 0;
7857 92 tempitem.misc10 = 0;
7858 92 tempitem.wpn4 = 0;
7859 92 tempitem.wpn5 = 0;
7860 92 tempitem.wpn6 = 0;
7861 92 tempitem.wpn7 = 0;
7862 92 tempitem.wpn8 = 0;
7863 92 tempitem.wpn9 = 0;
7864 92 tempitem.wpn10 = 0;
7865 92 break;
7866 }
7867 case itype_ring:
7868 {
7869 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7870 231 tempitem.misc2 = 0;
7871 231 tempitem.misc3 = 0;
7872 231 tempitem.misc4 = 0;
7873 231 tempitem.misc5 = 0;
7874 231 tempitem.misc6 = 0;
7875 231 tempitem.misc7 = 0;
7876 231 tempitem.misc8 = 0;
7877 231 tempitem.misc9 = 0;
7878 231 tempitem.misc10 = 0;
7879 231 tempitem.wpn = 0;
7880 231 tempitem.wpn2 = 0;
7881 231 tempitem.wpn3 = 0;
7882 231 tempitem.wpn4 = 0;
7883 231 tempitem.wpn5 = 0;
7884 231 tempitem.wpn6 = 0;
7885 231 tempitem.wpn7 = 0;
7886 231 tempitem.wpn8 = 0;
7887 231 tempitem.wpn9 = 0;
7888 231 tempitem.wpn10 = 0;
7889 231 break;
7890 }
7891 case itype_wallet:
7892 {
7893 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7894 231 tempitem.misc3 = 0;
7895 231 tempitem.misc4 = 0;
7896 231 tempitem.misc5 = 0;
7897 231 tempitem.misc6 = 0;
7898 231 tempitem.misc7 = 0;
7899 231 tempitem.misc8 = 0;
7900 231 tempitem.misc9 = 0;
7901 231 tempitem.misc10 = 0;
7902 231 tempitem.wpn = 0;
7903 231 tempitem.wpn2 = 0;
7904 231 tempitem.wpn3 = 0;
7905 231 tempitem.wpn4 = 0;
7906 231 tempitem.wpn5 = 0;
7907 231 tempitem.wpn6 = 0;
7908 231 tempitem.wpn7 = 0;
7909 231 tempitem.wpn8 = 0;
7910 231 tempitem.wpn9 = 0;
7911 231 tempitem.wpn10 = 0;
7912 231 break;
7913 }
7914 case itype_amulet:
7915 {
7916 152 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7917 152 tempitem.misc1 = 0;
7918 152 tempitem.misc2 = 0;
7919 152 tempitem.misc3 = 0;
7920 152 tempitem.misc4 = 0;
7921 152 tempitem.misc5 = 0;
7922 152 tempitem.misc6 = 0;
7923 152 tempitem.misc7 = 0;
7924 152 tempitem.misc8 = 0;
7925 152 tempitem.misc9 = 0;
7926 152 tempitem.misc10 = 0;
7927 152 tempitem.wpn = 0;
7928 152 tempitem.wpn2 = 0;
7929 152 tempitem.wpn3 = 0;
7930 152 tempitem.wpn4 = 0;
7931 152 tempitem.wpn5 = 0;
7932 152 tempitem.wpn6 = 0;
7933 152 tempitem.wpn7 = 0;
7934 152 tempitem.wpn8 = 0;
7935 152 tempitem.wpn9 = 0;
7936 152 tempitem.wpn10 = 0;
7937 152 break;
7938 }
7939 case itype_shield:
7940 {
7941 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7942 231 tempitem.misc3 = 0;
7943 231 tempitem.misc4 = 0;
7944 231 tempitem.misc5 = 0;
7945 231 tempitem.misc6 = 0;
7946 231 tempitem.misc7 = 0;
7947 231 tempitem.misc8 = 0;
7948 231 tempitem.misc9 = 0;
7949 231 tempitem.misc10 = 0;
7950 231 tempitem.wpn = 0;
7951 231 tempitem.wpn2 = 0;
7952 231 tempitem.wpn3 = 0;
7953 231 tempitem.wpn4 = 0;
7954 231 tempitem.wpn5 = 0;
7955 231 tempitem.wpn6 = 0;
7956 231 tempitem.wpn7 = 0;
7957 231 tempitem.wpn8 = 0;
7958 231 tempitem.wpn9 = 0;
7959 231 tempitem.wpn10 = 0;
7960 231 break;
7961 }
7962 case itype_bow:
7963 {
7964 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7965 154 tempitem.misc1 = 0;
7966 154 tempitem.misc2 = 0;
7967 154 tempitem.misc3 = 0;
7968 154 tempitem.misc4 = 0;
7969 154 tempitem.misc5 = 0;
7970 154 tempitem.misc6 = 0;
7971 154 tempitem.misc7 = 0;
7972 154 tempitem.misc8 = 0;
7973 154 tempitem.misc9 = 0;
7974 154 tempitem.misc10 = 0;
7975 154 tempitem.wpn = 0;
7976 154 tempitem.wpn2 = 0;
7977 154 tempitem.wpn3 = 0;
7978 154 tempitem.wpn4 = 0;
7979 154 tempitem.wpn5 = 0;
7980 154 tempitem.wpn6 = 0;
7981 154 tempitem.wpn7 = 0;
7982 154 tempitem.wpn8 = 0;
7983 154 tempitem.wpn9 = 0;
7984 154 tempitem.wpn10 = 0;
7985 154 break;
7986 }
7987 case itype_raft:
7988 {
7989 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7990 77 tempitem.misc1 = 0;
7991 77 tempitem.misc2 = 0;
7992 77 tempitem.misc3 = 0;
7993 77 tempitem.misc4 = 0;
7994 77 tempitem.misc5 = 0;
7995 77 tempitem.misc6 = 0;
7996 77 tempitem.misc7 = 0;
7997 77 tempitem.misc8 = 0;
7998 77 tempitem.misc9 = 0;
7999 77 tempitem.misc10 = 0;
8000 77 tempitem.wpn = 0;
8001 77 tempitem.wpn2 = 0;
8002 77 tempitem.wpn3 = 0;
8003 77 tempitem.wpn4 = 0;
8004 77 tempitem.wpn5 = 0;
8005 77 tempitem.wpn6 = 0;
8006 77 tempitem.wpn7 = 0;
8007 77 tempitem.wpn8 = 0;
8008 77 tempitem.wpn9 = 0;
8009 77 tempitem.wpn10 = 0;
8010 77 break;
8011 }
8012 case itype_ladder:
8013 {
8014 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8015 154 tempitem.misc1 = 0;
8016 154 tempitem.misc2 = 0;
8017 154 tempitem.misc3 = 0;
8018 154 tempitem.misc4 = 0;
8019 154 tempitem.misc5 = 0;
8020 154 tempitem.misc6 = 0;
8021 154 tempitem.misc7 = 0;
8022 154 tempitem.misc8 = 0;
8023 154 tempitem.misc9 = 0;
8024 154 tempitem.misc10 = 0;
8025 154 tempitem.wpn = 0;
8026 154 tempitem.wpn2 = 0;
8027 154 tempitem.wpn3 = 0;
8028 154 tempitem.wpn4 = 0;
8029 154 tempitem.wpn5 = 0;
8030 154 tempitem.wpn6 = 0;
8031 154 tempitem.wpn7 = 0;
8032 154 tempitem.wpn8 = 0;
8033 154 tempitem.wpn9 = 0;
8034 154 tempitem.wpn10 = 0;
8035 154 break;
8036 }
8037 case itype_book:
8038 {
8039 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8040 92 tempitem.misc1 = 0;
8041 92 tempitem.misc2 = 0;
8042 92 tempitem.misc3 = 0;
8043 92 tempitem.misc4 = 0;
8044 92 tempitem.misc5 = 0;
8045 92 tempitem.misc6 = 0;
8046 92 tempitem.misc7 = 0;
8047 92 tempitem.misc8 = 0;
8048 92 tempitem.misc9 = 0;
8049 92 tempitem.misc10 = 0;
8050 92 tempitem.wpn3 = 0;
8051 92 tempitem.wpn4 = 0;
8052 92 tempitem.wpn5 = 0;
8053 92 tempitem.wpn6 = 0;
8054 92 tempitem.wpn7 = 0;
8055 92 tempitem.wpn8 = 0;
8056 92 tempitem.wpn9 = 0;
8057 92 tempitem.wpn10 = 0;
8058 92 break;
8059 }
8060 case itype_magickey:
8061 {
8062 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8063 77 tempitem.misc1 = 0;
8064 77 tempitem.misc2 = 0;
8065 77 tempitem.misc3 = 0;
8066 77 tempitem.misc4 = 0;
8067 77 tempitem.misc5 = 0;
8068 77 tempitem.misc6 = 0;
8069 77 tempitem.misc7 = 0;
8070 77 tempitem.misc8 = 0;
8071 77 tempitem.misc9 = 0;
8072 77 tempitem.misc10 = 0;
8073 77 tempitem.wpn = 0;
8074 77 tempitem.wpn2 = 0;
8075 77 tempitem.wpn3 = 0;
8076 77 tempitem.wpn4 = 0;
8077 77 tempitem.wpn5 = 0;
8078 77 tempitem.wpn6 = 0;
8079 77 tempitem.wpn7 = 0;
8080 77 tempitem.wpn8 = 0;
8081 77 tempitem.wpn9 = 0;
8082 77 tempitem.wpn10 = 0;
8083 77 break;
8084 }
8085 case itype_bracelet:
8086 {
8087 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8088 231 tempitem.misc1 = 0;
8089 231 tempitem.misc2 = 0;
8090 231 tempitem.misc3 = 0;
8091 231 tempitem.misc4 = 0;
8092 231 tempitem.misc5 = 0;
8093 231 tempitem.misc6 = 0;
8094 231 tempitem.misc7 = 0;
8095 231 tempitem.misc8 = 0;
8096 231 tempitem.misc9 = 0;
8097 231 tempitem.misc10 = 0;
8098 231 tempitem.wpn = 0;
8099 231 tempitem.wpn2 = 0;
8100 231 tempitem.wpn3 = 0;
8101 231 tempitem.wpn4 = 0;
8102 231 tempitem.wpn5 = 0;
8103 231 tempitem.wpn6 = 0;
8104 231 tempitem.wpn7 = 0;
8105 231 tempitem.wpn8 = 0;
8106 231 tempitem.wpn9 = 0;
8107 231 tempitem.wpn10 = 0;
8108 231 break;
8109 }
8110 case itype_flippers:
8111 {
8112 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8113 77 tempitem.misc1 = 0;
8114 77 tempitem.misc2 = 0;
8115 77 tempitem.misc3 = 0;
8116 77 tempitem.misc4 = 0;
8117 77 tempitem.misc5 = 0;
8118 77 tempitem.misc6 = 0;
8119 77 tempitem.misc7 = 0;
8120 77 tempitem.misc8 = 0;
8121 77 tempitem.misc9 = 0;
8122 77 tempitem.misc10 = 0;
8123 77 tempitem.wpn = 0;
8124 77 tempitem.wpn2 = 0;
8125 77 tempitem.wpn3 = 0;
8126 77 tempitem.wpn4 = 0;
8127 77 tempitem.wpn5 = 0;
8128 77 tempitem.wpn6 = 0;
8129 77 tempitem.wpn7 = 0;
8130 77 tempitem.wpn8 = 0;
8131 77 tempitem.wpn9 = 0;
8132 77 tempitem.wpn10 = 0;
8133 77 break;
8134 }
8135 case itype_boots:
8136 {
8137 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8138 77 tempitem.misc1 = 0;
8139 77 tempitem.misc2 = 0;
8140 77 tempitem.misc3 = 0;
8141 77 tempitem.misc4 = 0;
8142 77 tempitem.misc5 = 0;
8143 77 tempitem.misc6 = 0;
8144 77 tempitem.misc7 = 0;
8145 77 tempitem.misc8 = 0;
8146 77 tempitem.misc9 = 0;
8147 77 tempitem.misc10 = 0;
8148 77 tempitem.wpn = 0;
8149 77 tempitem.wpn2 = 0;
8150 77 tempitem.wpn3 = 0;
8151 77 tempitem.wpn4 = 0;
8152 77 tempitem.wpn5 = 0;
8153 77 tempitem.wpn6 = 0;
8154 77 tempitem.wpn7 = 0;
8155 77 tempitem.wpn8 = 0;
8156 77 tempitem.wpn9 = 0;
8157 77 tempitem.wpn10 = 0;
8158 77 break;
8159 }
8160 case itype_hookshot:
8161 {
8162 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8163 154 tempitem.misc5 = 0;
8164 154 tempitem.misc6 = 0;
8165 154 tempitem.misc7 = 0;
8166 154 tempitem.misc8 = 0;
8167 154 tempitem.misc9 = 0;
8168 154 tempitem.misc10 = 0;
8169 154 tempitem.wpn5 = 0;
8170 154 tempitem.wpn6 = 0;
8171 154 tempitem.wpn7 = 0;
8172 154 tempitem.wpn8 = 0;
8173 154 tempitem.wpn9 = 0;
8174 154 tempitem.wpn10 = 0;
8175 154 break;
8176 }
8177 case itype_lens:
8178 {
8179 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8180 77 tempitem.misc2 = 0;
8181 77 tempitem.misc3 = 0;
8182 77 tempitem.misc4 = 0;
8183 77 tempitem.misc5 = 0;
8184 77 tempitem.misc6 = 0;
8185 77 tempitem.misc7 = 0;
8186 77 tempitem.misc8 = 0;
8187 77 tempitem.misc9 = 0;
8188 77 tempitem.misc10 = 0;
8189 77 tempitem.wpn = 0;
8190 77 tempitem.wpn2 = 0;
8191 77 tempitem.wpn3 = 0;
8192 77 tempitem.wpn4 = 0;
8193 77 tempitem.wpn5 = 0;
8194 77 tempitem.wpn6 = 0;
8195 77 tempitem.wpn7 = 0;
8196 77 tempitem.wpn8 = 0;
8197 77 tempitem.wpn9 = 0;
8198 77 tempitem.wpn10 = 0;
8199 77 break;
8200 }
8201 case itype_hammer:
8202 {
8203 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8204 77 tempitem.misc1 = 0;
8205 77 tempitem.misc2 = 0;
8206 77 tempitem.misc3 = 0;
8207 77 tempitem.misc4 = 0;
8208 77 tempitem.misc5 = 0;
8209 77 tempitem.misc6 = 0;
8210 77 tempitem.misc7 = 0;
8211 77 tempitem.misc8 = 0;
8212 77 tempitem.misc9 = 0;
8213 77 tempitem.misc10 = 0;
8214 77 tempitem.wpn3 = 0;
8215 77 tempitem.wpn4 = 0;
8216 77 tempitem.wpn5 = 0;
8217 77 tempitem.wpn6 = 0;
8218 77 tempitem.wpn7 = 0;
8219 77 tempitem.wpn8 = 0;
8220 77 tempitem.wpn9 = 0;
8221 77 tempitem.wpn10 = 0;
8222 77 break;
8223 }
8224 case itype_divinefire:
8225 {
8226 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8227 77 tempitem.misc3 = 0;
8228 77 tempitem.misc4 = 0;
8229 77 tempitem.misc5 = 0;
8230 77 tempitem.misc6 = 0;
8231 77 tempitem.misc7 = 0;
8232 77 tempitem.misc8 = 0;
8233 77 tempitem.misc9 = 0;
8234 77 tempitem.misc10 = 0;
8235 77 tempitem.wpn6 = 0;
8236 77 tempitem.wpn7 = 0;
8237 77 tempitem.wpn8 = 0;
8238 77 tempitem.wpn9 = 0;
8239 77 tempitem.wpn10 = 0;
8240 77 break;
8241 }
8242 case itype_divineescape:
8243 {
8244 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8245 77 tempitem.misc2 = 0;
8246 77 tempitem.misc3 = 0;
8247 77 tempitem.misc4 = 0;
8248 77 tempitem.misc5 = 0;
8249 77 tempitem.misc6 = 0;
8250 77 tempitem.misc7 = 0;
8251 77 tempitem.misc8 = 0;
8252 77 tempitem.misc9 = 0;
8253 77 tempitem.misc10 = 0;
8254 77 tempitem.wpn = 0;
8255 77 tempitem.wpn2 = 0;
8256 77 tempitem.wpn3 = 0;
8257 77 tempitem.wpn4 = 0;
8258 77 tempitem.wpn5 = 0;
8259 77 tempitem.wpn6 = 0;
8260 77 tempitem.wpn7 = 0;
8261 77 tempitem.wpn8 = 0;
8262 77 tempitem.wpn9 = 0;
8263 77 tempitem.wpn10 = 0;
8264 77 break;
8265 }
8266 case itype_divineprotection:
8267 {
8268 77 tempitem.flags &= ~ (ITEM_FLAG5);
8269 77 tempitem.misc2 = 0;
8270 77 tempitem.misc3 = 0;
8271 77 tempitem.misc4 = 0;
8272 77 tempitem.misc5 = 0;
8273 77 tempitem.misc6 = 0;
8274 77 tempitem.misc7 = 0;
8275 77 tempitem.misc8 = 0;
8276 77 tempitem.misc9 = 0;
8277 77 tempitem.misc10 = 0;
8278 77 break;
8279 }
8280 case itype_bomb:
8281 {
8282 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8283 92 tempitem.misc4 = 0;
8284 92 tempitem.misc5 = 0;
8285 92 tempitem.misc6 = 0;
8286 92 tempitem.misc7 = 0;
8287 92 tempitem.misc8 = 0;
8288 92 tempitem.misc9 = 0;
8289 92 tempitem.misc10 = 0;
8290 92 tempitem.wpn3 = 0;
8291 92 tempitem.wpn4 = 0;
8292 92 tempitem.wpn5 = 0;
8293 92 tempitem.wpn6 = 0;
8294 92 tempitem.wpn7 = 0;
8295 92 tempitem.wpn8 = 0;
8296 92 tempitem.wpn9 = 0;
8297 92 tempitem.wpn10 = 0;
8298 92 break;
8299 }
8300 case itype_sbomb:
8301 {
8302 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8303 77 tempitem.misc4 = 0;
8304 77 tempitem.misc5 = 0;
8305 77 tempitem.misc6 = 0;
8306 77 tempitem.misc7 = 0;
8307 77 tempitem.misc8 = 0;
8308 77 tempitem.misc9 = 0;
8309 77 tempitem.misc10 = 0;
8310 77 tempitem.wpn3 = 0;
8311 77 tempitem.wpn4 = 0;
8312 77 tempitem.wpn5 = 0;
8313 77 tempitem.wpn6 = 0;
8314 77 tempitem.wpn7 = 0;
8315 77 tempitem.wpn8 = 0;
8316 77 tempitem.wpn9 = 0;
8317 77 tempitem.wpn10 = 0;
8318 77 break;
8319 }
8320 case itype_clock:
8321 {
8322 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8323 77 tempitem.misc2 = 0;
8324 77 tempitem.misc3 = 0;
8325 77 tempitem.misc4 = 0;
8326 77 tempitem.misc5 = 0;
8327 77 tempitem.misc6 = 0;
8328 77 tempitem.misc7 = 0;
8329 77 tempitem.misc8 = 0;
8330 77 tempitem.misc9 = 0;
8331 77 tempitem.misc10 = 0;
8332 77 tempitem.wpn = 0;
8333 77 tempitem.wpn2 = 0;
8334 77 tempitem.wpn3 = 0;
8335 77 tempitem.wpn4 = 0;
8336 77 tempitem.wpn5 = 0;
8337 77 tempitem.wpn6 = 0;
8338 77 tempitem.wpn7 = 0;
8339 77 tempitem.wpn8 = 0;
8340 77 tempitem.wpn9 = 0;
8341 77 tempitem.wpn10 = 0;
8342 77 break;
8343 }
8344 case itype_key:
8345 {
8346 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8347 77 tempitem.misc1 = 0;
8348 77 tempitem.misc2 = 0;
8349 77 tempitem.misc3 = 0;
8350 77 tempitem.misc4 = 0;
8351 77 tempitem.misc5 = 0;
8352 77 tempitem.misc6 = 0;
8353 77 tempitem.misc7 = 0;
8354 77 tempitem.misc8 = 0;
8355 77 tempitem.misc9 = 0;
8356 77 tempitem.misc10 = 0;
8357 77 tempitem.wpn = 0;
8358 77 tempitem.wpn2 = 0;
8359 77 tempitem.wpn3 = 0;
8360 77 tempitem.wpn4 = 0;
8361 77 tempitem.wpn5 = 0;
8362 77 tempitem.wpn6 = 0;
8363 77 tempitem.wpn7 = 0;
8364 77 tempitem.wpn8 = 0;
8365 77 tempitem.wpn9 = 0;
8366 77 tempitem.wpn10 = 0;
8367 77 break;
8368 }
8369 case itype_magiccontainer:
8370 {
8371 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8372 77 tempitem.misc1 = 0;
8373 77 tempitem.misc2 = 0;
8374 77 tempitem.misc3 = 0;
8375 77 tempitem.misc4 = 0;
8376 77 tempitem.misc5 = 0;
8377 77 tempitem.misc6 = 0;
8378 77 tempitem.misc7 = 0;
8379 77 tempitem.misc8 = 0;
8380 77 tempitem.misc9 = 0;
8381 77 tempitem.misc10 = 0;
8382 77 tempitem.wpn = 0;
8383 77 tempitem.wpn2 = 0;
8384 77 tempitem.wpn3 = 0;
8385 77 tempitem.wpn4 = 0;
8386 77 tempitem.wpn5 = 0;
8387 77 tempitem.wpn6 = 0;
8388 77 tempitem.wpn7 = 0;
8389 77 tempitem.wpn8 = 0;
8390 77 tempitem.wpn9 = 0;
8391 77 tempitem.wpn10 = 0;
8392 77 break;
8393 }
8394 case itype_triforcepiece:
8395 {
8396 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8397 154 tempitem.misc3 = 0;
8398 154 tempitem.misc4 = 0;
8399 154 tempitem.misc5 = 0;
8400 154 tempitem.misc6 = 0;
8401 154 tempitem.misc7 = 0;
8402 154 tempitem.misc8 = 0;
8403 154 tempitem.misc9 = 0;
8404 154 tempitem.misc10 = 0;
8405 154 tempitem.wpn = 0;
8406 154 tempitem.wpn2 = 0;
8407 154 tempitem.wpn3 = 0;
8408 154 tempitem.wpn4 = 0;
8409 154 tempitem.wpn5 = 0;
8410 154 tempitem.wpn6 = 0;
8411 154 tempitem.wpn7 = 0;
8412 154 tempitem.wpn8 = 0;
8413 154 tempitem.wpn9 = 0;
8414 154 tempitem.wpn10 = 0;
8415 154 break;
8416 }
8417 case itype_map: case itype_compass: case itype_bosskey:
8418 {
8419 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8420 231 tempitem.misc1 = 0;
8421 231 tempitem.misc2 = 0;
8422 231 tempitem.misc3 = 0;
8423 231 tempitem.misc4 = 0;
8424 231 tempitem.misc5 = 0;
8425 231 tempitem.misc6 = 0;
8426 231 tempitem.misc7 = 0;
8427 231 tempitem.misc8 = 0;
8428 231 tempitem.misc9 = 0;
8429 231 tempitem.misc10 = 0;
8430 231 tempitem.wpn = 0;
8431 231 tempitem.wpn2 = 0;
8432 231 tempitem.wpn3 = 0;
8433 231 tempitem.wpn4 = 0;
8434 231 tempitem.wpn5 = 0;
8435 231 tempitem.wpn6 = 0;
8436 231 tempitem.wpn7 = 0;
8437 231 tempitem.wpn8 = 0;
8438 231 tempitem.wpn9 = 0;
8439 231 tempitem.wpn10 = 0;
8440 231 break;
8441 }
8442 case itype_quiver:
8443 {
8444 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8445 308 tempitem.misc3 = 0;
8446 308 tempitem.misc4 = 0;
8447 308 tempitem.misc5 = 0;
8448 308 tempitem.misc6 = 0;
8449 308 tempitem.misc7 = 0;
8450 308 tempitem.misc8 = 0;
8451 308 tempitem.misc9 = 0;
8452 308 tempitem.misc10 = 0;
8453 308 tempitem.wpn = 0;
8454 308 tempitem.wpn2 = 0;
8455 308 tempitem.wpn3 = 0;
8456 308 tempitem.wpn4 = 0;
8457 308 tempitem.wpn5 = 0;
8458 308 tempitem.wpn6 = 0;
8459 308 tempitem.wpn7 = 0;
8460 308 tempitem.wpn8 = 0;
8461 308 tempitem.wpn9 = 0;
8462 308 tempitem.wpn10 = 0;
8463 308 break;
8464 }
8465 case itype_lkey:
8466 {
8467 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8468 77 tempitem.misc1 = 0;
8469 77 tempitem.misc2 = 0;
8470 77 tempitem.misc3 = 0;
8471 77 tempitem.misc4 = 0;
8472 77 tempitem.misc5 = 0;
8473 77 tempitem.misc6 = 0;
8474 77 tempitem.misc7 = 0;
8475 77 tempitem.misc8 = 0;
8476 77 tempitem.misc9 = 0;
8477 77 tempitem.misc10 = 0;
8478 77 tempitem.wpn = 0;
8479 77 tempitem.wpn2 = 0;
8480 77 tempitem.wpn3 = 0;
8481 77 tempitem.wpn4 = 0;
8482 77 tempitem.wpn5 = 0;
8483 77 tempitem.wpn6 = 0;
8484 77 tempitem.wpn7 = 0;
8485 77 tempitem.wpn8 = 0;
8486 77 tempitem.wpn9 = 0;
8487 77 tempitem.wpn10 = 0;
8488 77 break;
8489 }
8490 case itype_cbyrna:
8491 {
8492 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8493 77 tempitem.misc4 = 0;
8494 77 tempitem.misc5 = 0;
8495 77 tempitem.misc6 = 0;
8496 77 tempitem.misc7 = 0;
8497 77 tempitem.misc8 = 0;
8498 77 tempitem.misc9 = 0;
8499 77 tempitem.misc10 = 0;
8500 77 tempitem.wpn6 = 0;
8501 77 tempitem.wpn7 = 0;
8502 77 tempitem.wpn8 = 0;
8503 77 tempitem.wpn9 = 0;
8504 77 tempitem.wpn10 = 0;
8505 77 break;
8506 }
8507 case itype_rupee: case itype_arrowammo:
8508 {
8509 970 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8510 970 tempitem.misc1 = 0;
8511 970 tempitem.misc2 = 0;
8512 970 tempitem.misc3 = 0;
8513 970 tempitem.misc4 = 0;
8514 970 tempitem.misc5 = 0;
8515 970 tempitem.misc6 = 0;
8516 970 tempitem.misc7 = 0;
8517 970 tempitem.misc8 = 0;
8518 970 tempitem.misc9 = 0;
8519 970 tempitem.misc10 = 0;
8520 970 tempitem.wpn = 0;
8521 970 tempitem.wpn2 = 0;
8522 970 tempitem.wpn3 = 0;
8523 970 tempitem.wpn4 = 0;
8524 970 tempitem.wpn5 = 0;
8525 970 tempitem.wpn6 = 0;
8526 970 tempitem.wpn7 = 0;
8527 970 tempitem.wpn8 = 0;
8528 970 tempitem.wpn9 = 0;
8529 970 tempitem.wpn10 = 0;
8530 970 break;
8531 }
8532 case itype_fairy:
8533 {
8534 136 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8535 136 tempitem.misc4 = 0;
8536 136 tempitem.misc5 = 0;
8537 136 tempitem.misc6 = 0;
8538 136 tempitem.misc7 = 0;
8539 136 tempitem.misc8 = 0;
8540 136 tempitem.misc9 = 0;
8541 136 tempitem.misc10 = 0;
8542 136 tempitem.wpn = 0;
8543 136 tempitem.wpn2 = 0;
8544 136 tempitem.wpn3 = 0;
8545 136 tempitem.wpn4 = 0;
8546 136 tempitem.wpn5 = 0;
8547 136 tempitem.wpn6 = 0;
8548 136 tempitem.wpn7 = 0;
8549 136 tempitem.wpn8 = 0;
8550 136 tempitem.wpn9 = 0;
8551 136 tempitem.wpn10 = 0;
8552 136 break;
8553 }
8554 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8555 {
8556 827 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8557 827 tempitem.misc1 = 0;
8558 827 tempitem.misc2 = 0;
8559 827 tempitem.misc3 = 0;
8560 827 tempitem.misc4 = 0;
8561 827 tempitem.misc5 = 0;
8562 827 tempitem.misc6 = 0;
8563 827 tempitem.misc7 = 0;
8564 827 tempitem.misc8 = 0;
8565 827 tempitem.misc9 = 0;
8566 827 tempitem.misc10 = 0;
8567 827 tempitem.wpn = 0;
8568 827 tempitem.wpn2 = 0;
8569 827 tempitem.wpn3 = 0;
8570 827 tempitem.wpn4 = 0;
8571 827 tempitem.wpn5 = 0;
8572 827 tempitem.wpn6 = 0;
8573 827 tempitem.wpn7 = 0;
8574 827 tempitem.wpn8 = 0;
8575 827 tempitem.wpn9 = 0;
8576 827 tempitem.wpn10 = 0;
8577 827 break;
8578 }
8579 case itype_bombbag:
8580 {
8581 308 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8582 308 tempitem.misc3 = 0;
8583 308 tempitem.misc4 = 0;
8584 308 tempitem.misc5 = 0;
8585 308 tempitem.misc6 = 0;
8586 308 tempitem.misc7 = 0;
8587 308 tempitem.misc8 = 0;
8588 308 tempitem.misc9 = 0;
8589 308 tempitem.misc10 = 0;
8590 308 tempitem.wpn = 0;
8591 308 tempitem.wpn2 = 0;
8592 308 tempitem.wpn3 = 0;
8593 308 tempitem.wpn4 = 0;
8594 308 tempitem.wpn5 = 0;
8595 308 tempitem.wpn6 = 0;
8596 308 tempitem.wpn7 = 0;
8597 308 tempitem.wpn8 = 0;
8598 308 tempitem.wpn9 = 0;
8599 308 tempitem.wpn10 = 0;
8600 308 break;
8601 }
8602 case itype_rocs:
8603 {
8604 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8605 77 tempitem.misc1 = 0;
8606 77 tempitem.misc2 = 0;
8607 77 tempitem.misc3 = 0;
8608 77 tempitem.misc4 = 0;
8609 77 tempitem.misc5 = 0;
8610 77 tempitem.misc6 = 0;
8611 77 tempitem.misc7 = 0;
8612 77 tempitem.misc8 = 0;
8613 77 tempitem.misc9 = 0;
8614 77 tempitem.misc10 = 0;
8615 77 tempitem.wpn = 0;
8616 77 tempitem.wpn2 = 0;
8617 77 tempitem.wpn3 = 0;
8618 77 tempitem.wpn4 = 0;
8619 77 tempitem.wpn5 = 0;
8620 77 tempitem.wpn6 = 0;
8621 77 tempitem.wpn7 = 0;
8622 77 tempitem.wpn8 = 0;
8623 77 tempitem.wpn9 = 0;
8624 77 tempitem.wpn10 = 0;
8625 77 break;
8626 }
8627 case itype_hoverboots:
8628 {
8629 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8630 77 tempitem.misc2 = 0;
8631 77 tempitem.misc3 = 0;
8632 77 tempitem.misc4 = 0;
8633 77 tempitem.misc5 = 0;
8634 77 tempitem.misc6 = 0;
8635 77 tempitem.misc7 = 0;
8636 77 tempitem.misc8 = 0;
8637 77 tempitem.misc9 = 0;
8638 77 tempitem.misc10 = 0;
8639 77 tempitem.wpn2 = 0;
8640 77 tempitem.wpn3 = 0;
8641 77 tempitem.wpn4 = 0;
8642 77 tempitem.wpn5 = 0;
8643 77 tempitem.wpn6 = 0;
8644 77 tempitem.wpn7 = 0;
8645 77 tempitem.wpn8 = 0;
8646 77 tempitem.wpn9 = 0;
8647 77 tempitem.wpn10 = 0;
8648 77 break;
8649 }
8650 case itype_spinscroll:
8651 {
8652 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8653 77 tempitem.misc2 = 0;
8654 77 tempitem.misc3 = 0;
8655 77 tempitem.misc4 = 0;
8656 77 tempitem.misc5 = 0;
8657 77 tempitem.misc6 = 0;
8658 77 tempitem.misc7 = 0;
8659 77 tempitem.misc8 = 0;
8660 77 tempitem.misc9 = 0;
8661 77 tempitem.misc10 = 0;
8662 77 tempitem.wpn = 0;
8663 77 tempitem.wpn2 = 0;
8664 77 tempitem.wpn3 = 0;
8665 77 tempitem.wpn4 = 0;
8666 77 tempitem.wpn5 = 0;
8667 77 tempitem.wpn6 = 0;
8668 77 tempitem.wpn7 = 0;
8669 77 tempitem.wpn8 = 0;
8670 77 tempitem.wpn9 = 0;
8671 77 tempitem.wpn10 = 0;
8672 77 break;
8673 }
8674 case itype_crossscroll:
8675 {
8676 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8677 77 tempitem.misc1 = 0;
8678 77 tempitem.misc2 = 0;
8679 77 tempitem.misc3 = 0;
8680 77 tempitem.misc4 = 0;
8681 77 tempitem.misc5 = 0;
8682 77 tempitem.misc6 = 0;
8683 77 tempitem.misc7 = 0;
8684 77 tempitem.misc8 = 0;
8685 77 tempitem.misc9 = 0;
8686 77 tempitem.misc10 = 0;
8687 77 tempitem.wpn = 0;
8688 77 tempitem.wpn2 = 0;
8689 77 tempitem.wpn3 = 0;
8690 77 tempitem.wpn4 = 0;
8691 77 tempitem.wpn5 = 0;
8692 77 tempitem.wpn6 = 0;
8693 77 tempitem.wpn7 = 0;
8694 77 tempitem.wpn8 = 0;
8695 77 tempitem.wpn9 = 0;
8696 77 tempitem.wpn10 = 0;
8697 77 break;
8698 }
8699 case itype_quakescroll:
8700 {
8701 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8702 77 tempitem.misc3 = 0;
8703 77 tempitem.misc4 = 0;
8704 77 tempitem.misc5 = 0;
8705 77 tempitem.misc6 = 0;
8706 77 tempitem.misc7 = 0;
8707 77 tempitem.misc8 = 0;
8708 77 tempitem.misc9 = 0;
8709 77 tempitem.misc10 = 0;
8710 77 tempitem.wpn = 0;
8711 77 tempitem.wpn2 = 0;
8712 77 tempitem.wpn3 = 0;
8713 77 tempitem.wpn4 = 0;
8714 77 tempitem.wpn5 = 0;
8715 77 tempitem.wpn6 = 0;
8716 77 tempitem.wpn7 = 0;
8717 77 tempitem.wpn8 = 0;
8718 77 tempitem.wpn9 = 0;
8719 77 tempitem.wpn10 = 0;
8720 77 break;
8721 }
8722 case itype_whispring:
8723 {
8724 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8725 154 tempitem.misc2 = 0;
8726 154 tempitem.misc3 = 0;
8727 154 tempitem.misc4 = 0;
8728 154 tempitem.misc5 = 0;
8729 154 tempitem.misc6 = 0;
8730 154 tempitem.misc7 = 0;
8731 154 tempitem.misc8 = 0;
8732 154 tempitem.misc9 = 0;
8733 154 tempitem.misc10 = 0;
8734 154 tempitem.wpn = 0;
8735 154 tempitem.wpn2 = 0;
8736 154 tempitem.wpn3 = 0;
8737 154 tempitem.wpn4 = 0;
8738 154 tempitem.wpn5 = 0;
8739 154 tempitem.wpn6 = 0;
8740 154 tempitem.wpn7 = 0;
8741 154 tempitem.wpn8 = 0;
8742 154 tempitem.wpn9 = 0;
8743 154 tempitem.wpn10 = 0;
8744 154 break;
8745 }
8746 case itype_chargering:
8747 {
8748 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8749 154 tempitem.misc3 = 0;
8750 154 tempitem.misc4 = 0;
8751 154 tempitem.misc5 = 0;
8752 154 tempitem.misc6 = 0;
8753 154 tempitem.misc7 = 0;
8754 154 tempitem.misc8 = 0;
8755 154 tempitem.misc9 = 0;
8756 154 tempitem.misc10 = 0;
8757 154 tempitem.wpn = 0;
8758 154 tempitem.wpn2 = 0;
8759 154 tempitem.wpn3 = 0;
8760 154 tempitem.wpn4 = 0;
8761 154 tempitem.wpn5 = 0;
8762 154 tempitem.wpn6 = 0;
8763 154 tempitem.wpn7 = 0;
8764 154 tempitem.wpn8 = 0;
8765 154 tempitem.wpn9 = 0;
8766 154 tempitem.wpn10 = 0;
8767 154 break;
8768 }
8769 case itype_perilscroll:
8770 {
8771 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8772 77 tempitem.misc2 = 0;
8773 77 tempitem.misc3 = 0;
8774 77 tempitem.misc4 = 0;
8775 77 tempitem.misc5 = 0;
8776 77 tempitem.misc6 = 0;
8777 77 tempitem.misc7 = 0;
8778 77 tempitem.misc8 = 0;
8779 77 tempitem.misc9 = 0;
8780 77 tempitem.misc10 = 0;
8781 77 tempitem.wpn = 0;
8782 77 tempitem.wpn2 = 0;
8783 77 tempitem.wpn3 = 0;
8784 77 tempitem.wpn4 = 0;
8785 77 tempitem.wpn5 = 0;
8786 77 tempitem.wpn6 = 0;
8787 77 tempitem.wpn7 = 0;
8788 77 tempitem.wpn8 = 0;
8789 77 tempitem.wpn9 = 0;
8790 77 tempitem.wpn10 = 0;
8791 77 break;
8792 }
8793 case itype_wealthmedal:
8794 {
8795 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8796 231 tempitem.misc2 = 0;
8797 231 tempitem.misc3 = 0;
8798 231 tempitem.misc4 = 0;
8799 231 tempitem.misc5 = 0;
8800 231 tempitem.misc6 = 0;
8801 231 tempitem.misc7 = 0;
8802 231 tempitem.misc8 = 0;
8803 231 tempitem.misc9 = 0;
8804 231 tempitem.misc10 = 0;
8805 231 tempitem.wpn = 0;
8806 231 tempitem.wpn2 = 0;
8807 231 tempitem.wpn3 = 0;
8808 231 tempitem.wpn4 = 0;
8809 231 tempitem.wpn5 = 0;
8810 231 tempitem.wpn6 = 0;
8811 231 tempitem.wpn7 = 0;
8812 231 tempitem.wpn8 = 0;
8813 231 tempitem.wpn9 = 0;
8814 231 tempitem.wpn10 = 0;
8815 231 break;
8816 }
8817 case itype_heartring:
8818 {
8819 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8820 231 tempitem.misc3 = 0;
8821 231 tempitem.misc4 = 0;
8822 231 tempitem.misc5 = 0;
8823 231 tempitem.misc6 = 0;
8824 231 tempitem.misc7 = 0;
8825 231 tempitem.misc8 = 0;
8826 231 tempitem.misc9 = 0;
8827 231 tempitem.misc10 = 0;
8828 231 tempitem.wpn = 0;
8829 231 tempitem.wpn2 = 0;
8830 231 tempitem.wpn3 = 0;
8831 231 tempitem.wpn4 = 0;
8832 231 tempitem.wpn5 = 0;
8833 231 tempitem.wpn6 = 0;
8834 231 tempitem.wpn7 = 0;
8835 231 tempitem.wpn8 = 0;
8836 231 tempitem.wpn9 = 0;
8837 231 tempitem.wpn10 = 0;
8838 231 break;
8839 }
8840 case itype_magicring:
8841 {
8842 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8843 308 tempitem.misc3 = 0;
8844 308 tempitem.misc4 = 0;
8845 308 tempitem.misc5 = 0;
8846 308 tempitem.misc6 = 0;
8847 308 tempitem.misc7 = 0;
8848 308 tempitem.misc8 = 0;
8849 308 tempitem.misc9 = 0;
8850 308 tempitem.misc10 = 0;
8851 308 tempitem.wpn = 0;
8852 308 tempitem.wpn2 = 0;
8853 308 tempitem.wpn3 = 0;
8854 308 tempitem.wpn4 = 0;
8855 308 tempitem.wpn5 = 0;
8856 308 tempitem.wpn6 = 0;
8857 308 tempitem.wpn7 = 0;
8858 308 tempitem.wpn8 = 0;
8859 308 tempitem.wpn9 = 0;
8860 308 tempitem.wpn10 = 0;
8861 308 break;
8862 }
8863 case itype_spinscroll2:
8864 {
8865 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8866 77 tempitem.misc2 = 0;
8867 77 tempitem.misc3 = 0;
8868 77 tempitem.misc4 = 0;
8869 77 tempitem.misc5 = 0;
8870 77 tempitem.misc6 = 0;
8871 77 tempitem.misc7 = 0;
8872 77 tempitem.misc8 = 0;
8873 77 tempitem.misc9 = 0;
8874 77 tempitem.misc10 = 0;
8875 77 tempitem.wpn = 0;
8876 77 tempitem.wpn2 = 0;
8877 77 tempitem.wpn3 = 0;
8878 77 tempitem.wpn4 = 0;
8879 77 tempitem.wpn5 = 0;
8880 77 tempitem.wpn6 = 0;
8881 77 tempitem.wpn7 = 0;
8882 77 tempitem.wpn8 = 0;
8883 77 tempitem.wpn9 = 0;
8884 77 tempitem.wpn10 = 0;
8885 77 break;
8886 }
8887 case itype_quakescroll2:
8888 {
8889 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8890 77 tempitem.misc3 = 0;
8891 77 tempitem.misc4 = 0;
8892 77 tempitem.misc5 = 0;
8893 77 tempitem.misc6 = 0;
8894 77 tempitem.misc7 = 0;
8895 77 tempitem.misc8 = 0;
8896 77 tempitem.misc9 = 0;
8897 77 tempitem.misc10 = 0;
8898 77 tempitem.wpn = 0;
8899 77 tempitem.wpn2 = 0;
8900 77 tempitem.wpn3 = 0;
8901 77 tempitem.wpn4 = 0;
8902 77 tempitem.wpn5 = 0;
8903 77 tempitem.wpn6 = 0;
8904 77 tempitem.wpn7 = 0;
8905 77 tempitem.wpn8 = 0;
8906 77 tempitem.wpn9 = 0;
8907 77 tempitem.wpn10 = 0;
8908 77 break;
8909 }
8910 case itype_agony:
8911 {
8912 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8913 77 tempitem.misc2 = 0;
8914 77 tempitem.misc3 = 0;
8915 77 tempitem.misc4 = 0;
8916 77 tempitem.misc5 = 0;
8917 77 tempitem.misc6 = 0;
8918 77 tempitem.misc7 = 0;
8919 77 tempitem.misc8 = 0;
8920 77 tempitem.misc9 = 0;
8921 77 tempitem.misc10 = 0;
8922 77 tempitem.wpn = 0;
8923 77 tempitem.wpn2 = 0;
8924 77 tempitem.wpn3 = 0;
8925 77 tempitem.wpn4 = 0;
8926 77 tempitem.wpn5 = 0;
8927 77 tempitem.wpn6 = 0;
8928 77 tempitem.wpn7 = 0;
8929 77 tempitem.wpn8 = 0;
8930 77 tempitem.wpn9 = 0;
8931 77 tempitem.wpn10 = 0;
8932 77 break;
8933 }
8934 case itype_stompboots:
8935 {
8936 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8937 77 tempitem.misc1 = 0;
8938 77 tempitem.misc2 = 0;
8939 77 tempitem.misc3 = 0;
8940 77 tempitem.misc4 = 0;
8941 77 tempitem.misc5 = 0;
8942 77 tempitem.misc6 = 0;
8943 77 tempitem.misc7 = 0;
8944 77 tempitem.misc8 = 0;
8945 77 tempitem.misc9 = 0;
8946 77 tempitem.misc10 = 0;
8947 77 tempitem.wpn = 0;
8948 77 tempitem.wpn2 = 0;
8949 77 tempitem.wpn3 = 0;
8950 77 tempitem.wpn4 = 0;
8951 77 tempitem.wpn5 = 0;
8952 77 tempitem.wpn6 = 0;
8953 77 tempitem.wpn7 = 0;
8954 77 tempitem.wpn8 = 0;
8955 77 tempitem.wpn9 = 0;
8956 77 tempitem.wpn10 = 0;
8957 77 break;
8958 }
8959 case itype_whimsicalring:
8960 {
8961 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8962 77 tempitem.misc2 = 0;
8963 77 tempitem.misc3 = 0;
8964 77 tempitem.misc4 = 0;
8965 77 tempitem.misc5 = 0;
8966 77 tempitem.misc6 = 0;
8967 77 tempitem.misc7 = 0;
8968 77 tempitem.misc8 = 0;
8969 77 tempitem.misc9 = 0;
8970 77 tempitem.misc10 = 0;
8971 77 tempitem.wpn = 0;
8972 77 tempitem.wpn2 = 0;
8973 77 tempitem.wpn3 = 0;
8974 77 tempitem.wpn4 = 0;
8975 77 tempitem.wpn5 = 0;
8976 77 tempitem.wpn6 = 0;
8977 77 tempitem.wpn7 = 0;
8978 77 tempitem.wpn8 = 0;
8979 77 tempitem.wpn9 = 0;
8980 77 tempitem.wpn10 = 0;
8981 77 break;
8982 }
8983 case itype_perilring:
8984 {
8985 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8986 77 tempitem.misc2 = 0;
8987 77 tempitem.misc3 = 0;
8988 77 tempitem.misc4 = 0;
8989 77 tempitem.misc5 = 0;
8990 77 tempitem.misc6 = 0;
8991 77 tempitem.misc7 = 0;
8992 77 tempitem.misc8 = 0;
8993 77 tempitem.misc9 = 0;
8994 77 tempitem.misc10 = 0;
8995 77 tempitem.wpn = 0;
8996 77 tempitem.wpn2 = 0;
8997 77 tempitem.wpn3 = 0;
8998 77 tempitem.wpn4 = 0;
8999 77 tempitem.wpn5 = 0;
9000 77 tempitem.wpn6 = 0;
9001 77 tempitem.wpn7 = 0;
9002 77 tempitem.wpn8 = 0;
9003 77 tempitem.wpn9 = 0;
9004 77 tempitem.wpn10 = 0;
9005 77 break;
9006 }
9007 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9008 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9009 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9010 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9011 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9012 {
9013 2017 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9014 2017 tempitem.misc1 = 0;
9015 2017 tempitem.misc2 = 0;
9016 2017 tempitem.misc3 = 0;
9017 2017 tempitem.misc4 = 0;
9018 2017 tempitem.misc5 = 0;
9019 2017 tempitem.misc6 = 0;
9020 2017 tempitem.misc7 = 0;
9021 2017 tempitem.misc8 = 0;
9022 2017 tempitem.misc9 = 0;
9023 2017 tempitem.misc10 = 0;
9024 2017 tempitem.wpn = 0;
9025 2017 tempitem.wpn2 = 0;
9026 2017 tempitem.wpn3 = 0;
9027 2017 tempitem.wpn4 = 0;
9028 2017 tempitem.wpn5 = 0;
9029 2017 tempitem.wpn6 = 0;
9030 2017 tempitem.wpn7 = 0;
9031 2017 tempitem.wpn8 = 0;
9032 2017 tempitem.wpn9 = 0;
9033 2017 tempitem.wpn10 = 0;
9034 2017 break;
9035 }
9036 }
9037 19712 }
9038 //Port quest rules to items
9039
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 31)
9040 {
9041
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_bomb)
9042 {
9043
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 86 times.
92 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9044 86 else tempitem.flags &= ~ ITEM_FLAG2;
9045 92 }
9046
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_sbomb)
9047 {
9048
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 71 times.
77 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9049 71 else tempitem.flags &= ~ ITEM_FLAG2;
9050 77 }
9051
9052
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 19312 times.
19543 else if(tempitem.family == itype_brang)
9053 {
9054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
231 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9055 231 else tempitem.flags &= ~ ITEM_FLAG4;
9056 231 }
9057
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 92 times.
19312 else if(tempitem.family == itype_wand)
9058 {
9059
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9060 90 else tempitem.flags &= ~ ITEM_FLAG3;
9061 92 }
9062 19712 }
9063
9064 //Port quest rules to items
9065
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 37)
9066 {
9067
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19635 times.
19712 if(tempitem.family == itype_flippers)
9068 {
9069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9070 77 else tempitem.flags &= ~ ITEM_FLAG1;
9071 77 }
9072
2/2
✓ Branch 0 taken 13161 times.
✓ Branch 1 taken 6474 times.
19635 else if(tempitem.family == itype_sword)
9073 {
9074
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9075 6405 else tempitem.flags &= ~ ITEM_FLAG5;
9076 6474 }
9077
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 13069 times.
13161 else if(tempitem.family == itype_wand)
9078 {
9079
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 89 times.
92 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9080 89 else tempitem.flags &= ~ ITEM_FLAG5;
9081 92 }
9082
4/4
✓ Branch 0 taken 12977 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 12785 times.
13069 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9083 {
9084 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9085
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 218 times.
284 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9086 218 else tempitem.flags &= ~ ITEM_FLAG3;
9087 284 }
9088 19712 }
9089
9090
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 38)
9091 {
9092
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 19327 times.
19712 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9093 {
9094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9095 385 else tempitem.flags &= ~ITEM_FLAG4;
9096
9097
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 375 times.
385 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9098 375 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9099 385 }
9100
2/2
✓ Branch 0 taken 19098 times.
✓ Branch 1 taken 229 times.
19327 else if(tempitem.family == itype_arrow)
9101 {
9102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
229 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9103 229 else tempitem.flags &= ~ITEM_FLAG4;
9104
9105
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 225 times.
229 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9106 225 else tempitem.flags |= ITEM_FLAG2;
9107 229 }
9108 19712 }
9109
9110
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 39)
9111 {
9112
6/6
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 19543 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 192 times.
✓ Branch 5 taken 19351 times.
19712 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9113 {
9114
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 12 times.
361 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9115 349 else tempitem.flags &= ~ITEM_FLAG5;
9116 361 }
9117
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 19198 times.
19351 else if(tempitem.family == itype_potion)
9118 {
9119
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 147 times.
153 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9120 {
9121 6 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9122 6 }
9123 else
9124 {
9125 147 tempitem.flags |= ITEM_FLAG3;
9126
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 62 times.
147 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9127 62 else tempitem.flags &= ~ITEM_FLAG4;
9128 }
9129 153 }
9130
2/2
✓ Branch 0 taken 19044 times.
✓ Branch 1 taken 154 times.
19198 else if(tempitem.family == itype_triforcepiece)
9131 {
9132
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
154 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9133 {
9134 12 tempitem.flags |= ITEM_FLAG3;
9135
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9136 6 else tempitem.flags &= ~ITEM_FLAG4;
9137 12 }
9138 else
9139 {
9140 142 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9141 }
9142 154 }
9143 19712 }
9144
9145
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 40)
9146 {
9147
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 19404 times.
19712 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9148 {
9149
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 288 times.
308 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9150 288 else tempitem.flags &= ~ITEM_FLAG1;
9151 308 }
9152
8/8
✓ Branch 0 taken 19212 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 12738 times.
✓ Branch 3 taken 6474 times.
✓ Branch 4 taken 12646 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 77 times.
✓ Branch 7 taken 12569 times.
19404 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9153 {
9154
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 6754 times.
6835 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9155 6754 else tempitem.flags &= ~ITEM_FLAG8;
9156 6835 }
9157
6/6
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
✓ Branch 2 taken 13146 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 13069 times.
19712 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9158 {
9159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
6643 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9160 6643 else tempitem.flags &= ~ITEM_FLAG7;
9161 6643 }
9162
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 77 times.
13069 else if(tempitem.family == itype_cbyrna)
9163 {
9164 77 tempitem.flags |= ITEM_FLAG7;
9165 77 }
9166 19712 }
9167
9168
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 41 )
9169 {
9170
2/2
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
19712 if(tempitem.family == itype_sword)
9171 {
9172
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9173 6405 else tempitem.flags &= ~ITEM_FLAG9;
9174
9175
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9176 6405 else tempitem.flags &= ~ITEM_FLAG10;
9177 6474 }
9178 19712 }
9179
9180
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 42 )
9181 {
9182
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_wand)
9183 {
9184
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9185 90 else tempitem.flags &= ~ITEM_FLAG3;
9186
9187 92 tempitem.flags &= ~ITEM_FLAG6;
9188 92 }
9189
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_hammer)
9190 {
9191 77 tempitem.flags &= ~ITEM_FLAG3;
9192 77 }
9193
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19466 times.
19543 else if(tempitem.family == itype_cbyrna)
9194 {
9195 77 tempitem.flags |= ITEM_FLAG3;
9196
9197 77 tempitem.flags &= ~ITEM_FLAG6;
9198 77 }
9199
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 6474 times.
19466 else if(tempitem.family == itype_sword)
9200 {
9201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6474 times.
6474 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9202 6474 else tempitem.flags &= ~ITEM_FLAG6;
9203 6474 }
9204 19712 }
9205
9206
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 43 )
9207 {
9208
2/2
✓ Branch 0 taken 19589 times.
✓ Branch 1 taken 123 times.
19712 if(tempitem.family == itype_whistle)
9209 {
9210
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 120 times.
123 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9211 120 else tempitem.flags &= ~ITEM_FLAG3;
9212 123 }
9213 19712 }
9214
9215
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 45 )
9216 {
9217
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_flippers)
9218 {
9219 77 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9220 77 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9221 77 }
9222 19712 }
9223
9224
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 46 )
9225 {
9226
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_raft)
9227 {
9228 77 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9229 77 }
9230 19712 }
9231
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 34 ) //! set the default counter for older quests.
9232 {
9233
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 19643 times.
19712 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9234 {
9235 69 tempitem.cost_counter[0] = 1;
9236 69 }
9237 else
9238 {
9239
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 17595 times.
19643 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9240 2048 tempitem.cost_counter[0] = 4;
9241 else
9242 {
9243 17595 tempitem.cost_amount[0] = 0;
9244 17595 tempitem.cost_counter[0] = -1;
9245 }
9246 }
9247 19712 }
9248
9249
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 35 ) //new Lens of Truth flags
9250 {
9251
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if ( tempitem.family == itype_lens )
9252 {
9253
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if ( get_bit(quest_rules,qr_RAFTLENS) )
9254 {
9255 3 tempitem.flags |= ITEM_FLAG4;
9256 3 }
9257
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 if ( get_bit(quest_rules,qr_LENSHINTS) )
9258 {
9259 39 tempitem.flags |= ITEM_FLAG1;
9260 39 }
9261
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 73 times.
77 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9262 {
9263 4 tempitem.flags |= ITEM_FLAG5;
9264 4 }
9265 77 }
9266 19712 }
9267
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9268 {
9269
2/2
✓ Branch 0 taken 157696 times.
✓ Branch 1 taken 19712 times.
177408 for ( int32_t q = 0; q < 8; q++ )
9270 {
9271 157696 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9272 157696 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9273 157696 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9274 157696 tempitem.sprite_initiald[q] = 0;
9275 157696 }
9276
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19712 times.
59136 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9277 19712 tempitem.sprite_script = 0;
9278 19712 }
9279
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9280 {
9281 19712 tempitem.pickupflag = 0;
9282 19712 }
9283
9284
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 51 )
9285 {
9286
2/2
✓ Branch 0 taken 19520 times.
✓ Branch 1 taken 192 times.
19712 if( tempitem.family == itype_candle )
9287 {
9288 192 tempitem.misc4 = 50; //Step speed
9289 192 }
9290 19712 }
9291
9292
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 52 )
9293 {
9294
2/2
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
19712 if( tempitem.family == itype_shield )
9295 231 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9296 19712 }
9297
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if(s_version < 53)
9298 {
9299
4/4
✓ Branch 0 taken 19314 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 77 times.
19712 switch(tempitem.family)
9300 {
9301 case itype_arrow:
9302 229 tempitem.cost_counter[1] = crARROWS;
9303 229 tempitem.cost_amount[1] = 1;
9304 229 break;
9305 case itype_bomb:
9306 92 tempitem.cost_counter[1] = crBOMBS;
9307 92 tempitem.cost_amount[1] = 1;
9308 92 break;
9309 case itype_sbomb:
9310 77 tempitem.cost_counter[1] = crSBOMBS;
9311 77 tempitem.cost_amount[1] = 1;
9312 77 break;
9313 default:
9314 19314 tempitem.cost_counter[1] = crNONE;
9315 19314 tempitem.cost_amount[1] = 0;
9316 19314 }
9317 19712 tempitem.magiccosttimer[1] = 0;
9318 19712 }
9319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if( s_version < 54 )
9320 {
9321
2/2
✓ Branch 0 taken 25244 times.
✓ Branch 1 taken 100 times.
25344 if( tempitem.family == itype_flippers )
9322 100 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9323 25344 }
9324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version < 55)
9325 {
9326
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 24948 times.
25344 switch(tempitem.family)
9327 {
9328 case itype_spinscroll:
9329 case itype_quakescroll:
9330 198 tempitem.usesound2 = WAV_ZN1CHARGE;
9331 198 break;
9332 case itype_spinscroll2:
9333 case itype_quakescroll2:
9334 198 tempitem.usesound2 = WAV_ZN1CHARGE2;
9335 198 break;
9336 }
9337 25344 }
9338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version < 56)
9339 {
9340
4/4
✓ Branch 0 taken 24893 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 114 times.
25344 switch(tempitem.family)
9341 {
9342 case itype_divinefire:
9343
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9344
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9345 99 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9346 99 break;
9347 case itype_candle:
9348
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 122 times.
238 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9349 238 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9350 238 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9351 238 break;
9352 case itype_book:
9353 114 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9354 114 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9355 114 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9356 114 break;
9357 }
9358 25344 }
9359
9360
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 24942 times.
25344 if(tempitem.fam_type==0) // Always do this
9361 402 tempitem.fam_type=1;
9362
9363 25344 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9364 25344 }
9365 99 }
9366
9367 99 return 0;
9368 99 }
9369
9370 static bool did_init_def_items = false;
9371 50445 void init_def_items()
9372 {
9373
2/2
✓ Branch 0 taken 50416 times.
✓ Branch 1 taken 29 times.
50445 if(did_init_def_items) return;
9374 29 did_init_def_items = true;
9375 29 default_items[3].cost_counter[1] = crBOMBS;
9376 29 default_items[13].cost_counter[1] = crARROWS;
9377 29 default_items[14].cost_counter[1] = crARROWS;
9378 29 default_items[48].cost_counter[1] = crSBOMBS;
9379 29 default_items[57].cost_counter[1] = crARROWS;
9380 50445 }
9381 50445 void reset_itembuf(itemdata *item, int32_t id)
9382 {
9383 50445 init_def_items();
9384
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 28410 times.
50445 if(id<iLast)
9385 {
9386 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9387 28410 word tile = item->tile;
9388 28410 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9389 28410 int32_t ltm = item->ltm;
9390
9391 28410 memcpy(item,&default_items[id],sizeof(itemdata));
9392 28410 item->tile = tile;
9393 28410 item->misc_flags = miscs;
9394 28410 item->csets = cset;
9395 28410 item->frames = frames;
9396 28410 item->speed = speed;
9397 28410 item->delay = delay;
9398 28410 item->ltm = ltm;
9399 28410 }
9400 50445 }
9401
9402 8192 void reset_itemname(int32_t id)
9403 {
9404 8192 sprintf(item_string[id],"zz%03d",id);
9405
9406
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 4576 times.
8192 if(id < iLast)
9407 4576 strcpy(item_string[id],old_item_string[id]);
9408 8192 }
9409
9410 99 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9411 {
9412 99 word weapons_to_read=MAXWPNS;
9413 int32_t dummy;
9414 byte padding;
9415 wpndata tempweapon;
9416 99 word s_version=0, s_cversion=0;
9417
9418
9419
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x186)
9420 {
9421 weapons_to_read=64;
9422 }
9423
9424
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x185)
9425 {
9426 weapons_to_read=32;
9427 }
9428
9429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
9430 {
9431 99 weapons_to_read=0;
9432
9433 //section version info
9434
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
9435 {
9436 return qe_invalid;
9437 }
9438
9439 99 FFCore.quest_format[vWeaponSprites] = s_version;
9440
9441 //al_trace("Weapons version %d\n", s_version);
9442
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
9443 {
9444 return qe_invalid;
9445 }
9446
9447 //section size
9448
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
9449 {
9450 return qe_invalid;
9451 }
9452
9453 //finally... section data
9454
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&weapons_to_read,f,true))
9455 {
9456 return qe_invalid;
9457 }
9458 99 }
9459
9460
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>2)
9461 {
9462
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<weapons_to_read; i++)
9463 {
9464 char tempname[64];
9465
9466
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
9467 {
9468 return qe_invalid;
9469 }
9470
9471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
9472 {
9473 24576 strcpy(weapon_string[i], tempname);
9474 24576 }
9475 24576 }
9476
9477
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<4)
9478 {
9479 if(keepdata)
9480 {
9481 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9482 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9483 }
9484 }
9485
9486
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<5)
9487 {
9488 if(keepdata)
9489 {
9490 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9491 }
9492 }
9493
9494 /*
9495 if (s_version<6)
9496 {
9497 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9498 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9499 }
9500 */
9501 96 }
9502 else
9503 {
9504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
9505
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<WPNCNT; i++)
9506 771 reset_weaponname(i);
9507 }
9508
9509
2/2
✓ Branch 0 taken 24780 times.
✓ Branch 1 taken 99 times.
24879 for(int32_t i=0; i<weapons_to_read; i++)
9510 {
9511 24780 word oldtile = 0;
9512
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 20940 times.
24780 if (s_version < 8)
9513 {
9514
1/2
✓ Branch 0 taken 20940 times.
✗ Branch 1 not taken.
20940 if (!p_igetw(&oldtile, f, true))
9515 return qe_invalid;
9516 20940 }
9517
9518
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.misc,f,true))
9519 {
9520 return qe_invalid;
9521 }
9522
9523
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.csets,f,true))
9524 {
9525 return qe_invalid;
9526 }
9527
9528
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.frames,f,true))
9529 {
9530 return qe_invalid;
9531 }
9532
9533
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.speed,f,true))
9534 {
9535 return qe_invalid;
9536 }
9537
9538
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.type,f,true))
9539 {
9540 return qe_invalid;
9541 }
9542
9543
2/2
✓ Branch 0 taken 19148 times.
✓ Branch 1 taken 5632 times.
24780 if ( s_version >= 7 )
9544 {
9545
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempweapon.script,f,true))
9546 {
9547 return qe_invalid;
9548 }
9549
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempweapon.tile,f,true))
9550 {
9551 return qe_invalid;
9552 }
9553 5632 }
9554
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19148 times.
24780 if ( s_version < 7 )
9555 {
9556 19148 tempweapon.tile = oldtile;
9557 19148 }
9558
9559
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(Header->zelda_version < 0x193)
9560 {
9561 if(!p_getc(&padding,f,true))
9562 {
9563 return qe_invalid;
9564 }
9565 }
9566
9567
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 204 times.
24780 if(s_version < 6)
9568 {
9569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(i==ewFIRETRAIL)
9570 {
9571 tempweapon.misc |= WF_BEHIND;
9572 }
9573 else
9574 204 tempweapon.misc &= ~WF_BEHIND;
9575 204 }
9576
9577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24780 times.
24780 if(keepdata==true)
9578 {
9579 24780 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9580 24780 }
9581 24780 }
9582
9583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
9584 {
9585
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
9586 {
9587 3 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9588 3 }
9589
9590
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
9591 {
9592 3 wpnsbuf[iwQuarterHearts].tile=1;
9593 3 wpnsbuf[iwQuarterHearts].csets=1;
9594 3 }
9595
9596
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x176)
9597 {
9598 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9599 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9600 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9601 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9602 }
9603
9604
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
9605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9606 {
9607 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9608 }
9609
9610
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if((Header->zelda_version < 0x210))
9611 {
9612 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9613 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9614 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9615 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9616 }
9617 99 }
9618
9619 99 return 0;
9620 99 }
9621
9622 99 void init_guys(int32_t guyversion)
9623 {
9624
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
9625 {
9626 50688 guysbuf[i] = default_guys[0];
9627 50688 }
9628
9629
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 99 times.
17622 for(int32_t i=0; i<OLDMAXGUYS; i++)
9630 {
9631 17523 guysbuf[i] = default_guys[i];
9632
2/2
✓ Branch 0 taken 17325 times.
✓ Branch 1 taken 198 times.
17523 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9633 17523 guysbuf[i].spr_death = iwDeath;
9634 17523 guysbuf[i].spr_spawn = iwSpawn;
9635 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9636
4/4
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 16992 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 3 times.
17523 if(guyversion<=3 && i==ePATRABS)
9637 {
9638 3 guysbuf[i].bosspal=spDIG;
9639 3 guysbuf[i].cset=14;
9640 3 guysbuf[i].misc9=14;
9641 3 }
9642
9643
2/2
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 531 times.
17523 if(guyversion<=3)
9644 {
9645 // Rope/Ghini Flash rules
9646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9647 {
9648
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eROPE2)
9649 {
9650 3 guysbuf[i].flags2 &= ~guy_flashing;
9651 3 }
9652 531 }
9653
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9655 {
9656
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9657 {
9658 18 guysbuf[i].flags2 &= ~guy_flashing;
9659 18 }
9660 531 }
9661
9662
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eGHINI2)
9663 {
9664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9665 {
9666 3 guysbuf[i].flags2 |= guy_blinking;
9667 3 }
9668
9669
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9670 {
9671 guysbuf[i].flags2 |= guy_transparent;
9672 }
9673 3 }
9674 531 }
9675
9676 // Darknut fix
9677
10/10
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17325 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 17226 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 17127 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 17028 times.
17523 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9678 {
9679
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 180 times.
495 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9680 {
9681 315 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9682 315 guysbuf[i].s_width=guysbuf[i].e_width;
9683 315 guysbuf[i].s_height=guysbuf[i].e_height;
9684 315 }
9685 180 else guysbuf[i].s_tile=860;
9686
9687
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 15 times.
495 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9688 {
9689 15 guysbuf[i].flags |= guy_bkshield;
9690 15 }
9691 495 }
9692
9693
3/4
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17523 times.
✗ Branch 3 not taken.
17523 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9694 {
9695 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9696 }
9697 17523 }
9698 99 }
9699
9700 768 void reset_weaponname(int32_t i)
9701 {
9702
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 504 times.
768 if(i<wLast)
9703 {
9704 264 strcpy(weapon_string[i],old_weapon_string[i]);
9705 264 }
9706 else
9707 504 sprintf(weapon_string[i],"zz%03d",i);
9708 768 }
9709
9710 99 void init_item_drop_sets()
9711 {
9712
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9713 {
9714 // item_drop_sets[i] = default_item_drop_sets[0];
9715 25344 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9716 25344 }
9717
9718
2/2
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 99 times.
1386 for(int32_t i=0; i<isMAX; i++)
9719 {
9720 1287 item_drop_sets[i] = default_item_drop_sets[i];
9721
9722 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9723
2/2
✓ Branch 0 taken 12870 times.
✓ Branch 1 taken 1287 times.
14157 for(int32_t j=0; j<10; ++j)
9724 {
9725 12870 int32_t it = item_drop_sets[i].item[j];
9726
9727
3/4
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 3762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 588 times.
12870 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9728
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 8520 times.
9108 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9729 {
9730 588 item_drop_sets[i].chance[j+1]=0;
9731 588 }
9732
3/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 11886 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
12282 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9733 {
9734 item_drop_sets[i].chance[j+1]=0;
9735 }
9736
9737 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9738
2/2
✓ Branch 0 taken 12862 times.
✓ Branch 1 taken 8 times.
12870 if(itemsbuf[it].family == itype_misc)
9739 {
9740 // If a non-gameplay item was selected, then item drop was aborted.
9741 // Reflect this by increasing the 'Nothing' chance accordingly.
9742 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9743 8 item_drop_sets[i].chance[j+1]=0;
9744 8 }
9745 12870 }
9746 1287 }
9747 99 }
9748
9749 99 void init_favorites()
9750 {
9751
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9752 {
9753 19800 favorite_combos[i]=-1;
9754 19800 }
9755
9756
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9757 {
9758 19800 favorite_comboaliases[i]=-1;
9759 19800 }
9760 99 }
9761
9762 const char *ctype_name[cMAX]=
9763 {
9764 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9765 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9766 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9767 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9768 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9769 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9770 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9771 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9772 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9773 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9774 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9775 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9776 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9777 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9778 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9779 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9780 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9781 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9782 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9783 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9784 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9785 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9786 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9787 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9788 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9789 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9790 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9791 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9792
9793 };
9794
9795 178 int32_t init_combo_classes()
9796 {
9797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9798
2/2
✓ Branch 0 taken 31684 times.
✓ Branch 1 taken 178 times.
31862 for(int32_t i=0; i<cMAX; i++)
9799 {
9800 31684 combo_class_buf[i] = default_combo_classes[i];
9801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31684 times.
31684 if ( char const* nm = zi->getComboTypeName(i) )
9802 {
9803 31684 size_t len = strlen(nm);
9804
2/2
✓ Branch 0 taken 2027776 times.
✓ Branch 1 taken 31684 times.
2059460 for ( size_t q = 0; q < 64; q++ )
9805 {
9806
2/2
✓ Branch 0 taken 469208 times.
✓ Branch 1 taken 1558568 times.
2027776 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9807 2027776 }
9808 31684 }
9809 31684 }
9810
9811 178 return 0;
9812 }
9813
9814 77 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9815 {
9816
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 assert(v_herosprites < 6);
9817 //these are here to bypass compiler warnings about unused arguments
9818 77 cv_herosprites=cv_herosprites;
9819
9820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(keepdata)
9821 {
9822 77 zinit.hero_swim_speed=67; //default
9823 77 setupherotiles(zinit.heroAnimationStyle);
9824 77 setupherodefenses();
9825 77 setupherooffsets();
9826 77 }
9827
9828
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(v_herosprites>=0)
9829 {
9830 word tile, tile2;
9831 byte flip, extend, dummy_byte;
9832
9833
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9834 {
9835
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9836 {
9837 return qe_invalid;
9838 }
9839
9840
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9841 {
9842 return qe_invalid;
9843 }
9844
9845
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9846 {
9847 return qe_invalid;
9848 }
9849
9850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9851 {
9852 296 walkspr[i][spr_tile]=(int32_t)tile;
9853 296 walkspr[i][spr_flip]=(int32_t)flip;
9854 296 walkspr[i][spr_extend]=(int32_t)extend;
9855 296 }
9856 296 }
9857
9858
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9859 {
9860
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9861 {
9862 return qe_invalid;
9863 }
9864
9865
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9866 {
9867 return qe_invalid;
9868 }
9869
9870
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9871 {
9872 return qe_invalid;
9873 }
9874
9875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9876 {
9877 296 stabspr[i][spr_tile]=(int32_t)tile;
9878 296 stabspr[i][spr_flip]=(int32_t)flip;
9879 296 stabspr[i][spr_extend]=(int32_t)extend;
9880 296 }
9881 296 }
9882
9883
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9884 {
9885
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9886 {
9887 return qe_invalid;
9888 }
9889
9890
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9891 {
9892 return qe_invalid;
9893 }
9894
9895
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9896 {
9897 return qe_invalid;
9898 }
9899
9900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9901 {
9902 296 slashspr[i][spr_tile]=(int32_t)tile;
9903 296 slashspr[i][spr_flip]=(int32_t)flip;
9904 296 slashspr[i][spr_extend]=(int32_t)extend;
9905 296 }
9906 296 }
9907
9908
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9909 {
9910
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9911 {
9912 return qe_invalid;
9913 }
9914
9915
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9916 {
9917 return qe_invalid;
9918 }
9919
9920
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9921 {
9922 return qe_invalid;
9923 }
9924
9925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9926 {
9927 296 floatspr[i][spr_tile]=(int32_t)tile;
9928 296 floatspr[i][spr_flip]=(int32_t)flip;
9929 296 floatspr[i][spr_extend]=(int32_t)extend;
9930 296 }
9931 296 }
9932
9933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>1)
9934 {
9935
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9936 {
9937
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9938 {
9939 return qe_invalid;
9940 }
9941
9942
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9943 {
9944 return qe_invalid;
9945 }
9946
9947
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9948 {
9949 return qe_invalid;
9950 }
9951
9952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9953 {
9954 296 swimspr[i][spr_tile]=(int32_t)tile;
9955 296 swimspr[i][spr_flip]=(int32_t)flip;
9956 296 swimspr[i][spr_extend]=(int32_t)extend;
9957 296 }
9958 296 }
9959 74 }
9960
9961
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9962 {
9963
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9964 {
9965 return qe_invalid;
9966 }
9967
9968
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9969 {
9970 return qe_invalid;
9971 }
9972
9973
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9974 {
9975 return qe_invalid;
9976 }
9977
9978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9979 {
9980 296 divespr[i][spr_tile]=(int32_t)tile;
9981 296 divespr[i][spr_flip]=(int32_t)flip;
9982 296 divespr[i][spr_extend]=(int32_t)extend;
9983 296 }
9984 296 }
9985
9986
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9987 {
9988
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9989 {
9990 return qe_invalid;
9991 }
9992
9993
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9994 {
9995 return qe_invalid;
9996 }
9997
9998
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9999 {
10000 return qe_invalid;
10001 }
10002
10003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10004 {
10005 296 poundspr[i][spr_tile]=(int32_t)tile;
10006 296 poundspr[i][spr_flip]=(int32_t)flip;
10007 296 poundspr[i][spr_extend]=(int32_t)extend;
10008 296 }
10009 296 }
10010
10011
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&tile,f,keepdata))
10012 {
10013 return qe_invalid;
10014 }
10015
10016 74 flip=0;
10017
10018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>0)
10019 {
10020
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&flip,f,keepdata))
10021 {
10022 return qe_invalid;
10023 }
10024 74 }
10025
10026
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&extend,f,keepdata))
10027 {
10028 return qe_invalid;
10029 }
10030
10031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10032 {
10033 74 castingspr[spr_tile]=(int32_t)tile;
10034 74 castingspr[spr_flip]=(int32_t)flip;
10035 74 castingspr[spr_extend]=(int32_t)extend;
10036 74 }
10037
10038
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(v_herosprites>0)
10039 {
10040 74 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10041
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 74 times.
222 for(int32_t i=0; i<2; i++)
10042 {
10043
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 148 times.
444 for(int32_t j=0; j<num_holdsprs; j++)
10044 {
10045
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10046 {
10047 return qe_invalid;
10048 }
10049
10050
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10051 {
10052 return qe_invalid;
10053 }
10054
10055
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10056 {
10057 return qe_invalid;
10058 }
10059
10060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10061 {
10062 296 holdspr[i][j][spr_tile]=(int32_t)tile;
10063 296 holdspr[i][j][spr_flip]=(int32_t)flip;
10064 296 holdspr[i][j][spr_extend]=(int32_t)extend;
10065 296 }
10066 296 }
10067 148 }
10068 74 }
10069 else
10070 {
10071 for(int32_t i=0; i<2; i++)
10072 {
10073 if(!p_igetw(&tile,f,keepdata))
10074 {
10075 return qe_invalid;
10076 }
10077
10078 if(!p_igetw(&tile2,f,keepdata))
10079 {
10080 return qe_invalid;
10081 }
10082
10083 if(!p_getc(&extend,f,keepdata))
10084 {
10085 return qe_invalid;
10086 }
10087
10088 if(keepdata)
10089 {
10090 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10091 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10092 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10093 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10094 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10095 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10096 }
10097 }
10098 }
10099
10100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>2)
10101 {
10102
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10103 {
10104
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10105 {
10106 return qe_invalid;
10107 }
10108
10109
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10110 {
10111 return qe_invalid;
10112 }
10113
10114
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10115 {
10116 return qe_invalid;
10117 }
10118
10119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10120 {
10121 296 jumpspr[i][spr_tile]=(int32_t)tile;
10122 296 jumpspr[i][spr_flip]=(int32_t)flip;
10123 296 jumpspr[i][spr_extend]=(int32_t)extend;
10124 296 }
10125 296 }
10126 74 }
10127
10128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>3)
10129 {
10130
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10131 {
10132
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10133 {
10134 return qe_invalid;
10135 }
10136
10137
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10138 {
10139 return qe_invalid;
10140 }
10141
10142
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10143 {
10144 return qe_invalid;
10145 }
10146
10147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10148 {
10149 296 chargespr[i][spr_tile]=(int32_t)tile;
10150 296 chargespr[i][spr_flip]=(int32_t)flip;
10151 296 chargespr[i][spr_extend]=(int32_t)extend;
10152 296 }
10153 296 }
10154 74 }
10155
10156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>4)
10157 {
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(!p_getc(&dummy_byte,f,keepdata))
10159 {
10160 return qe_invalid;
10161 }
10162
10163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10164 {
10165 74 zinit.hero_swim_speed=(byte)dummy_byte;
10166 74 }
10167 74 }
10168
10169
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(keepdata)
10170 {
10171 74 memset(frozenspr, 0, sizeof(frozenspr));
10172 74 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10173 74 memset(onfirespr, 0, sizeof(onfirespr));
10174 74 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10175 74 memset(diggingspr, 0, sizeof(diggingspr));
10176 74 memset(usingrodspr, 0, sizeof(usingrodspr));
10177 74 memset(usingcanespr, 0, sizeof(usingcanespr));
10178 74 memset(pushingspr, 0, sizeof(pushingspr));
10179 74 memset(liftingspr, 0, sizeof(liftingspr));
10180 74 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10181 74 memset(stunnedspr, 0, sizeof(stunnedspr));
10182 74 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10183 74 memset(fallingspr, 0, sizeof(fallingspr));
10184 74 memset(shockedspr, 0, sizeof(shockedspr));
10185 74 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10186 74 memset(pullswordspr, 0, sizeof(pullswordspr));
10187 74 memset(readingspr, 0, sizeof(readingspr));
10188 74 memset(slash180spr, 0, sizeof(slash180spr));
10189 74 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10190 74 memset(dashspr, 0, sizeof(dashspr));
10191 74 memset(bonkspr, 0, sizeof(bonkspr));
10192 74 memset(medallionsprs, 0, sizeof(medallionsprs));
10193 74 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10194 74 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10195
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t q = 0; q < 4; ++q)
10196 {
10197
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 296 times.
1184 for(int32_t p = 0; p < 3; ++p)
10198 {
10199 888 drowningspr[q][p] = divespr[q][p];
10200 888 drowning_lavaspr[q][p] = divespr[q][p];
10201 888 }
10202 296 }
10203 74 memset(sideswimspr, 0, sizeof(sideswimspr));
10204 74 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10205 74 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10206 74 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10207 74 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10208 74 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10209 74 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10210 74 }
10211 74 }
10212
10213 77 return 0;
10214 77 }
10215
10216 3740 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10217 {
10218 3740 arr[spr_tile] = tile;
10219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_flip] = (flip > 3 ? 0 : flip);
10220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_extend] = (ext > 2 ? 0 : ext);
10221 3740 }
10222 //Used to read the player sprites as int32_t, not word.
10223 22 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10224 {
10225 //these are here to bypass compiler warnings about unused arguments
10226 22 cv_herosprites=cv_herosprites;
10227
10228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10229 {
10230 22 zinit.hero_swim_speed=67; //default
10231 22 setupherotiles(zinit.heroAnimationStyle);
10232 22 setupherodefenses();
10233 22 setupherooffsets();
10234 22 }
10235
10236 int32_t tile, tile2;
10237 byte flip, extend, dummy_byte;
10238
10239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>=0)
10240 {
10241
10242
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10243 {
10244
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10245 {
10246 return qe_invalid;
10247 }
10248
10249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10250 {
10251 return qe_invalid;
10252 }
10253
10254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10255 {
10256 return qe_invalid;
10257 }
10258
10259 88 if(keepdata)
10260 {
10261 88 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10262 88 }
10263 88 }
10264
10265
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10266 {
10267
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10268 {
10269 return qe_invalid;
10270 }
10271
10272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10273 {
10274 return qe_invalid;
10275 }
10276
10277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10283 {
10284 88 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10285 88 }
10286 88 }
10287
10288
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10289 {
10290
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10291 {
10292 return qe_invalid;
10293 }
10294
10295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10296 {
10297 return qe_invalid;
10298 }
10299
10300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10301 {
10302 return qe_invalid;
10303 }
10304
10305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10306 {
10307 88 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10308 88 }
10309 88 }
10310
10311
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10312 {
10313
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10314 {
10315 return qe_invalid;
10316 }
10317
10318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10319 {
10320 return qe_invalid;
10321 }
10322
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10324 {
10325 return qe_invalid;
10326 }
10327
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10329 {
10330 88 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10331 88 }
10332 88 }
10333
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>1)
10335 {
10336
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10337 {
10338
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10339 {
10340 return qe_invalid;
10341 }
10342
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10344 {
10345 return qe_invalid;
10346 }
10347
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10349 {
10350 return qe_invalid;
10351 }
10352
10353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10354 {
10355 88 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10356 88 }
10357 88 }
10358 22 }
10359
10360
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10361 {
10362
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10363 {
10364 return qe_invalid;
10365 }
10366
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10368 {
10369 return qe_invalid;
10370 }
10371
10372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10373 {
10374 return qe_invalid;
10375 }
10376
10377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10378 {
10379 88 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10380 88 }
10381 88 }
10382
10383
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10384 {
10385
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10386 {
10387 return qe_invalid;
10388 }
10389
10390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10391 {
10392 return qe_invalid;
10393 }
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10396 {
10397 return qe_invalid;
10398 }
10399
10400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10401 {
10402 88 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10403 88 }
10404 88 }
10405
10406
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
10407 {
10408 return qe_invalid;
10409 }
10410
10411 22 flip=0;
10412
10413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>0)
10414 {
10415
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
10416 {
10417 return qe_invalid;
10418 }
10419 22 }
10420
10421
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
10422 {
10423 return qe_invalid;
10424 }
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10427 {
10428 22 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10429 22 }
10430
10431
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>0)
10432 {
10433 22 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10434
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
66 for(int32_t i=0; i<2; i++)
10435 {
10436
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 44 times.
176 for(int32_t j=0; j<num_holdsprs; j++)
10437 {
10438
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tile,f,keepdata))
10439 {
10440 return qe_invalid;
10441 }
10442
10443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&flip,f,keepdata))
10444 {
10445 return qe_invalid;
10446 }
10447
10448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&extend,f,keepdata))
10449 {
10450 return qe_invalid;
10451 }
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(keepdata)
10454 {
10455 132 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10456 132 }
10457 132 }
10458 44 }
10459 22 }
10460 else
10461 {
10462 for(int32_t i=0; i<2; i++)
10463 {
10464 if(!p_igetl(&tile,f,keepdata))
10465 {
10466 return qe_invalid;
10467 }
10468
10469 if(!p_igetl(&tile2,f,keepdata))
10470 {
10471 return qe_invalid;
10472 }
10473
10474 if(!p_getc(&extend,f,keepdata))
10475 {
10476 return qe_invalid;
10477 }
10478
10479 if(keepdata)
10480 {
10481 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10482 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10483 }
10484 }
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>2)
10488 {
10489
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10490 {
10491
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10492 {
10493 return qe_invalid;
10494 }
10495
10496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10497 {
10498 return qe_invalid;
10499 }
10500
10501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10502 {
10503 return qe_invalid;
10504 }
10505
10506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10507 {
10508 88 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10509 88 }
10510 88 }
10511 22 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>3)
10514 {
10515
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10516 {
10517
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10518 {
10519 return qe_invalid;
10520 }
10521
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10523 {
10524 return qe_invalid;
10525 }
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10528 {
10529 return qe_invalid;
10530 }
10531
10532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10533 {
10534 88 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10535 88 }
10536 88 }
10537 22 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>4)
10540 {
10541
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&dummy_byte,f,keepdata))
10542 {
10543 return qe_invalid;
10544 }
10545
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10547 {
10548 22 zinit.hero_swim_speed=(byte)dummy_byte;
10549 22 }
10550 22 }
10551
10552
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>6)
10553 {
10554
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10555 {
10556
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10557 return qe_invalid;
10558
10559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10560 return qe_invalid;
10561
10562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10563 return qe_invalid;
10564
10565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10566 {
10567 88 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10568 88 }
10569 88 }
10570
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10571 {
10572
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10573 return qe_invalid;
10574
10575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10576 return qe_invalid;
10577
10578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10579 return qe_invalid;
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10582 {
10583 88 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10584 88 }
10585 88 }
10586
10587
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10588 {
10589
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10590 return qe_invalid;
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10593 return qe_invalid;
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10596 return qe_invalid;
10597
10598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10599 {
10600 88 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10601 88 }
10602 88 }
10603
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10604 {
10605
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10606 return qe_invalid;
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10609 return qe_invalid;
10610
10611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10612 return qe_invalid;
10613
10614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10615 {
10616 88 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10617 88 }
10618 88 }
10619
10620
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10621 {
10622
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10623 return qe_invalid;
10624
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10626 return qe_invalid;
10627
10628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10629 return qe_invalid;
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10632 {
10633 88 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10634 88 }
10635 88 }
10636
10637
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10638 {
10639
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10640 return qe_invalid;
10641
10642
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10643 return qe_invalid;
10644
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10646 return qe_invalid;
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10649 {
10650 88 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10651 88 }
10652 88 }
10653
10654
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10655 {
10656
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10657 return qe_invalid;
10658
10659
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10660 return qe_invalid;
10661
10662
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10663 return qe_invalid;
10664
10665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10666 {
10667 88 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10668 88 }
10669 88 }
10670
10671
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10672 {
10673
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10674 return qe_invalid;
10675
10676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10677 return qe_invalid;
10678
10679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10680 return qe_invalid;
10681
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10683 {
10684 88 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10685 88 }
10686 88 }
10687
10688
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10689 {
10690
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10691 return qe_invalid;
10692
10693
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10694 return qe_invalid;
10695
10696
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10697 return qe_invalid;
10698
10699 88 byte frames = 0;
10700
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 80 times.
88 if(v_herosprites > 15)
10701 {
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!p_getc(&frames,f,keepdata))
10703 return qe_invalid;
10704 80 }
10705
10706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10707 {
10708 88 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10709 88 liftingspr[q][spr_frames] = frames;
10710 88 }
10711 88 }
10712
10713
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10714 {
10715
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10716 return qe_invalid;
10717
10718
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10719 return qe_invalid;
10720
10721
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10722 return qe_invalid;
10723
10724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10725 {
10726 88 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10727 88 }
10728 88 }
10729
10730
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10731 {
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10733 return qe_invalid;
10734
10735
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10736 return qe_invalid;
10737
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10739 return qe_invalid;
10740
10741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10742 {
10743 88 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10744 88 }
10745 88 }
10746
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10747 {
10748
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10749 return qe_invalid;
10750
10751
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10752 return qe_invalid;
10753
10754
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10755 return qe_invalid;
10756
10757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10758 {
10759 88 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 88 }
10761 88 }
10762
10763
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10764 {
10765
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10766 return qe_invalid;
10767
10768
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10769 return qe_invalid;
10770
10771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10772 return qe_invalid;
10773
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10775 {
10776 88 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10777 88 }
10778 88 }
10779
10780
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10781 {
10782
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10783 return qe_invalid;
10784
10785
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10786 return qe_invalid;
10787
10788
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10789 return qe_invalid;
10790
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10792 {
10793 88 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 88 }
10795 88 }
10796
10797
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10798 {
10799
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10800 return qe_invalid;
10801
10802
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10803 return qe_invalid;
10804
10805
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10806 return qe_invalid;
10807
10808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10809 {
10810 88 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10811 88 }
10812 88 }
10813
10814
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10815 {
10816
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10820 return qe_invalid;
10821
10822
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10823 return qe_invalid;
10824
10825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10826 {
10827 88 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10828 88 }
10829 88 }
10830
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10831 {
10832
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10833 return qe_invalid;
10834
10835
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10836 return qe_invalid;
10837
10838
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10839 return qe_invalid;
10840
10841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10842 {
10843 88 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10844 88 }
10845 88 }
10846
10847
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10848 {
10849
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10850 return qe_invalid;
10851
10852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10853 return qe_invalid;
10854
10855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10856 return qe_invalid;
10857
10858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10859 {
10860 88 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10861 88 }
10862 88 }
10863
10864
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10865 {
10866
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10867 return qe_invalid;
10868
10869
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10873 return qe_invalid;
10874
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10876 {
10877 88 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10878 88 }
10879 88 }
10880
10881
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10882 {
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10884 return qe_invalid;
10885
10886
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10887 return qe_invalid;
10888
10889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10890 return qe_invalid;
10891
10892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10893 {
10894 88 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10895 88 }
10896 88 }
10897
10898
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10899 {
10900
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10901 return qe_invalid;
10902
10903
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10904 return qe_invalid;
10905
10906
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10907 return qe_invalid;
10908
10909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10910 {
10911 88 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10912 88 }
10913 88 }
10914
10915
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10916 {
10917
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10918 return qe_invalid;
10919
10920
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10921 return qe_invalid;
10922
10923
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10924 return qe_invalid;
10925
10926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10927 {
10928 88 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10929 88 }
10930 88 }
10931
10932
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10933 {
10934
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10935 return qe_invalid;
10936
10937
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10938 return qe_invalid;
10939
10940
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10941 return qe_invalid;
10942
10943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10944 {
10945 88 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10946 88 }
10947 88 }
10948
10949
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10950 {
10951
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
10952 return qe_invalid;
10953
10954
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&flip,f,keepdata))
10955 return qe_invalid;
10956
10957
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&extend,f,keepdata))
10958 return qe_invalid;
10959
10960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
10961 {
10962 66 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10963 66 }
10964 66 }
10965 22 }
10966 else if(keepdata)
10967 {
10968 memset(frozenspr, 0, sizeof(frozenspr));
10969 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10970 memset(onfirespr, 0, sizeof(onfirespr));
10971 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10972 memset(diggingspr, 0, sizeof(diggingspr));
10973 memset(usingrodspr, 0, sizeof(usingrodspr));
10974 memset(usingcanespr, 0, sizeof(usingcanespr));
10975 memset(pushingspr, 0, sizeof(pushingspr));
10976 memset(liftingspr, 0, sizeof(liftingspr));
10977 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10978 memset(stunnedspr, 0, sizeof(stunnedspr));
10979 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10980 memset(fallingspr, 0, sizeof(fallingspr));
10981 memset(shockedspr, 0, sizeof(shockedspr));
10982 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10983 memset(pullswordspr, 0, sizeof(pullswordspr));
10984 memset(readingspr, 0, sizeof(readingspr));
10985 memset(slash180spr, 0, sizeof(slash180spr));
10986 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10987 memset(dashspr, 0, sizeof(dashspr));
10988 memset(bonkspr, 0, sizeof(bonkspr));
10989 memset(medallionsprs, 0, sizeof(medallionsprs));
10990 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10991 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10992 for(int32_t q = 0; q < 4; ++q)
10993 {
10994 for(int32_t p = 0; p < 3; ++p)
10995 {
10996 drowningspr[q][p] = divespr[q][p];
10997 drowning_lavaspr[q][p] = divespr[q][p];
10998 }
10999 }
11000 }
11001
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 8)
11002 {
11003
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11004 {
11005
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11006 return qe_invalid;
11007
11008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11009 return qe_invalid;
11010
11011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11012 return qe_invalid;
11013
11014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11015 {
11016 88 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11017 88 }
11018 88 }
11019 22 }
11020 else if (keepdata)
11021 {
11022 memset(sideswimspr, 0, sizeof(sideswimspr));
11023 }
11024
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 9)
11025 {
11026
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11027 {
11028
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11032 return qe_invalid;
11033
11034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11038 {
11039 88 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11040 88 }
11041 88 }
11042
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11043 {
11044
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11045 return qe_invalid;
11046
11047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11048 return qe_invalid;
11049
11050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11051 return qe_invalid;
11052
11053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11054 {
11055 88 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11056 88 }
11057 88 }
11058
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11059 {
11060
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11061 return qe_invalid;
11062
11063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11064 return qe_invalid;
11065
11066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11067 return qe_invalid;
11068
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11070 {
11071 88 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11072 88 }
11073 88 }
11074
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11075 {
11076
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11077 return qe_invalid;
11078
11079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11080 return qe_invalid;
11081
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11086 {
11087 88 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11088 88 }
11089 88 }
11090 22 }
11091 else if (keepdata)
11092 {
11093 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11094 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11095 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11096 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11097 }
11098
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 10)
11099 {
11100
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11101 {
11102 int32_t hmr;
11103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&hmr,f,keepdata))
11104 return qe_invalid;
11105
11106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11107 {
11108 88 hammeroffsets[q] = hmr;
11109 88 }
11110 88 }
11111 22 }
11112 else if (keepdata)
11113 {
11114 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11115 }
11116
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 11)
11117 {
11118
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q)
11119 {
11120
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
11121 return qe_invalid;
11122
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&flip,f,keepdata))
11124 return qe_invalid;
11125
11126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&extend,f,keepdata))
11127 return qe_invalid;
11128
11129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
11130 {
11131 66 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11132 66 }
11133 66 }
11134 22 }
11135 else if (keepdata)
11136 {
11137 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11138 }
11139
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 12)
11140 {
11141
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
11142 return qe_invalid;
11143
11144
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
11145 return qe_invalid;
11146
11147
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
11148 return qe_invalid;
11149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (keepdata)
11150 {
11151 22 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11152 22 }
11153
11154 22 }
11155 else if (keepdata)
11156 {
11157 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11158 }
11159
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 13)
11160 {
11161
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11162 {
11163
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11164 return qe_invalid;
11165
11166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11170 return qe_invalid;
11171
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11173 {
11174 88 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11175 88 }
11176 88 }
11177 22 }
11178 else if (keepdata)
11179 {
11180 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11181 }
11182
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 14)
11183 {
11184
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11185 {
11186
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11187 return qe_invalid;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11190 return qe_invalid;
11191
11192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11193 return qe_invalid;
11194
11195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11196 {
11197 88 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11198 88 }
11199 88 }
11200 22 }
11201 else if (keepdata)
11202 {
11203 memset(revslashspr, 0, sizeof(revslashspr));
11204 }
11205
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 7)
11206 {
11207 22 int32_t num_defense = wMax;
11208 22 byte def = 0;
11209
11210 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11211 /*if(v_herosprites > [x])
11212 * {
11213 * num_defense = 146 //value of wMax on version 8
11214 * }
11215 */
11216
11217
2/2
✓ Branch 0 taken 3212 times.
✓ Branch 1 taken 22 times.
3234 for (int32_t q = 0; q < num_defense; q++)
11218 {
11219
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if (!p_getc(&def, f, keepdata))
11220 return qe_invalid;
11221
11222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3212 times.
3212 if (keepdata)
11223 {
11224 3212 hero_defence[q] = def;
11225 3212 }
11226 3212 }
11227 22 }
11228 else if (keepdata)
11229 {
11230 int32_t num_defense = wMax;
11231 for (int32_t q = 0; q < num_defense; q++)
11232 {
11233 hero_defence[q] = 0;
11234 }
11235 }
11236 22 }
11237
11238 22 return 0;
11239 22 }
11240
11241
11242 96 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11243 {
11244 //these are here to bypass compiler warnings about unused arguments
11245 96 Header=Header;
11246
11247 dword dummy;
11248 96 word s_version=0, s_cversion=0;
11249
11250 //section version info
11251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 96 FFCore.quest_format[vHeroSprites] = s_version;
11257
11258 //al_trace("Player sprites version %d\n", s_version);
11259
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11260 {
11261 return qe_invalid;
11262 }
11263
11264 //section size
11265
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11266 {
11267 return qe_invalid;
11268 }
11269
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 6 )
11270 {
11271 //al_trace("Reading Player Sprites v6\n");
11272 22 return readherosprites3(f, s_version, dummy, keepdata);
11273 }
11274 74 else return readherosprites2(f, s_version, dummy, keepdata);
11275 96 }
11276
11277 96 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11278 {
11279 int32_t dummy;
11280 96 word s_version=0, s_cversion=0;
11281
11282 //section version info
11283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11284 {
11285 return qe_invalid;
11286 }
11287
11288 96 FFCore.quest_format[vSubscreen] = s_version;
11289
11290 //al_trace("Subscreens version %d\n", s_version);
11291
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11292 {
11293 return qe_invalid;
11294 }
11295
11296 //section size
11297
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11298 {
11299 return qe_invalid;
11300 }
11301
11302 //finally... section data
11303
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 96 times.
12384 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11304 {
11305 12288 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11306
11307
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(ret!=0) return ret;
11308 12288 }
11309
11310 96 return 0;
11311 96 }
11312
11313 12288 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11314 {
11315 12288 int32_t numsub=0;
11316 12288 byte temp_ss=0;
11317 subscreen_object temp_sub_stack;
11318 12288 subscreen_object *temp_sub = &temp_sub_stack;
11319
11320 char tempname[64];
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!pfread(tempname,64,f,true))
11323 {
11324 return qe_invalid;
11325 }
11326
11327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version > 1)
11328 {
11329
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&temp_ss,f,keepdata))
11330 {
11331 return qe_invalid;
11332 }
11333 12288 }
11334
11335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version < 4)
11336 {
11337 uint8_t tmp=0;
11338
11339 if(!p_getc(&tmp,f,true))
11340 {
11341 return qe_invalid;
11342 }
11343
11344 numsub = (int32_t)tmp;
11345 }
11346 else
11347 {
11348 word tmp;
11349
11350
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tmp, f, true))
11351 {
11352 return qe_invalid;
11353 }
11354
11355 12288 numsub = (int32_t)tmp;
11356 }
11357
11358 int32_t j;
11359
11360
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32006 times.
✓ Branch 2 taken 19718 times.
✓ Branch 3 taken 12288 times.
32006 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11361 {
11362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11363 {
11364 19718 memset(temp_sub,0,sizeof(subscreen_object));
11365
11366
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 18571 times.
19718 switch(custom_subscreen[i].objects[j].type)
11367 {
11368 case ssoTEXT:
11369 case ssoTEXTBOX:
11370 case ssoCURRENTITEMTEXT:
11371 case ssoCURRENTITEMCLASSTEXT:
11372
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
✓ Branch 2 taken 1147 times.
✗ Branch 3 not taken.
1147 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11373
11374 //fall through
11375 default:
11376 19718 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11377 19718 break;
11378 }
11379 19718 }
11380
11381
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->type),f,true))
11382 {
11383 return qe_invalid;
11384 }
11385
11386
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->pos),f,keepdata))
11387 {
11388 return qe_invalid;
11389 }
11390
11391
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(s_version < 5)
11392 {
11393 switch(temp_sub->pos)
11394 {
11395 case 0:
11396 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11397 break;
11398
11399 case 1:
11400 temp_sub->pos = sspUP;
11401 break;
11402
11403 case 2:
11404 temp_sub->pos = sspDOWN;
11405 break;
11406
11407 default:
11408 temp_sub->pos = 0;
11409 }
11410 }
11411
11412
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->x),f,keepdata))
11413 {
11414 return qe_invalid;
11415 }
11416
11417
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->y),f,keepdata))
11418 {
11419 return qe_invalid;
11420 }
11421
11422
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->w),f,keepdata))
11423 {
11424 return qe_invalid;
11425 }
11426
11427
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->h),f,keepdata))
11428 {
11429 return qe_invalid;
11430 }
11431
11432
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11433 {
11434 return qe_invalid;
11435 }
11436
11437
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11438 {
11439 return qe_invalid;
11440 }
11441
11442
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11443 {
11444 return qe_invalid;
11445 }
11446
11447
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11448 {
11449 return qe_invalid;
11450 }
11451
11452
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11453 {
11454 return qe_invalid;
11455 }
11456
11457
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11458 {
11459 return qe_invalid;
11460 }
11461
11462
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11463 {
11464 return qe_invalid;
11465 }
11466
11467
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11468 {
11469 return qe_invalid;
11470 }
11471
11472
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11473 {
11474 return qe_invalid;
11475 }
11476
11477
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11478 {
11479 return qe_invalid;
11480 }
11481
11482
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11483 {
11484 return qe_invalid;
11485 }
11486
11487
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11488 {
11489 return qe_invalid;
11490 }
11491
11492
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11493 {
11494 return qe_invalid;
11495 }
11496
11497
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11498 {
11499 return qe_invalid;
11500 }
11501
11502
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11503 {
11504 return qe_invalid;
11505 }
11506
11507
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11508 {
11509 return qe_invalid;
11510 }
11511
11512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(s_version < 2)
11513 {
11514 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11515 {
11516 return qe_invalid;
11517 }
11518
11519 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11520 {
11521 return qe_invalid;
11522 }
11523
11524 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11525 {
11526 return qe_invalid;
11527 }
11528 }
11529 else
11530 {
11531
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->speed),f,keepdata))
11532 {
11533 return qe_invalid;
11534 }
11535
11536
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->delay),f,keepdata))
11537 {
11538 return qe_invalid;
11539 }
11540
11541
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11542 {
11543 return qe_invalid;
11544 }
11545 }
11546
11547 19718 int32_t temp_size=0;
11548
11549 // bool deletets = false;
11550
4/4
✓ Branch 0 taken 8380 times.
✓ Branch 1 taken 1605 times.
✓ Branch 2 taken 9590 times.
✓ Branch 3 taken 143 times.
19718 switch(temp_sub->type)
11551 {
11552 case ssoTEXT:
11553 case ssoTEXTBOX:
11554 case ssoCURRENTITEMTEXT:
11555 case ssoCURRENTITEMCLASSTEXT:
11556 word temptempsize;
11557 /*uint8_t temp1;
11558 uint8_t temp2;
11559 temp2 = 0;
11560 if(!p_getc(&temp1,f,true))
11561 {
11562 return qe_invalid;
11563 }
11564 if(temp1)
11565 {
11566
11567 if(!p_getc(&temp2,f,true))
11568 {
11569 return qe_invalid;
11570 }
11571 }*/
11572
11573
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!p_igetw(&temptempsize,f,true))
11574 {
11575 return qe_invalid;
11576 }
11577
11578 //temptempsize = temp1 + (temp2 << 8);
11579 1605 temp_size = (int32_t)temptempsize;
11580
11581 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(keepdata)
11583 {
11584 1605 uint32_t char_length = temp_size+1;
11585 1605 temp_sub->dp1 = new char[char_length]; //memory not freed
11586
11587 //deletets = true; //obsolete
11588 1605 }
11589
11590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(temp_size)
11591 {
11592
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11593 {
11594 return qe_invalid;
11595 }
11596 1605 }
11597
11598 1605 break;
11599
11600 case ssoLIFEMETER:
11601
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11602 temp_sub->d3 = 1;
11603
11604
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11605 {
11606 return qe_invalid;
11607 }
11608
11609 143 break;
11610
11611
11612 case ssoCURRENTITEM:
11613
11614
1/2
✓ Branch 0 taken 8380 times.
✗ Branch 1 not taken.
8380 if(s_version < 6)
11615 {
11616 switch(temp_sub->d1)
11617 {
11618 case ssiBOMB:
11619 temp_sub->d1 = itype_bomb;
11620 break;
11621
11622 case ssiSWORD:
11623 temp_sub->d1 = itype_sword;
11624 break;
11625
11626 case ssiSHIELD:
11627 temp_sub->d1 = itype_shield;
11628 break;
11629
11630 case ssiCANDLE:
11631 temp_sub->d1 = itype_candle;
11632 break;
11633
11634 case ssiLETTER:
11635 temp_sub->d1 = itype_letter;
11636 break;
11637
11638 case ssiPOTION:
11639 temp_sub->d1 = itype_potion;
11640 break;
11641
11642 case ssiLETTERPOTION:
11643 temp_sub->d1 = itype_letterpotion;
11644 break;
11645
11646 case ssiBOW:
11647 temp_sub->d1 = itype_bow;
11648 break;
11649
11650 case ssiARROW:
11651 temp_sub->d1 = itype_arrow;
11652 break;
11653
11654 case ssiBOWANDARROW:
11655 temp_sub->d1 = itype_bowandarrow;
11656 break;
11657
11658 case ssiBAIT:
11659 temp_sub->d1 = itype_bait;
11660 break;
11661
11662 case ssiRING:
11663 temp_sub->d1 = itype_ring;
11664 break;
11665
11666 case ssiBRACELET:
11667 temp_sub->d1 = itype_bracelet;
11668 break;
11669
11670 case ssiMAP:
11671 temp_sub->d1 = itype_map;
11672 break;
11673
11674 case ssiCOMPASS:
11675 temp_sub->d1 = itype_compass;
11676 break;
11677
11678 case ssiBOSSKEY:
11679 temp_sub->d1 = itype_bosskey;
11680 break;
11681
11682 case ssiMAGICKEY:
11683 temp_sub->d1 = itype_magickey;
11684 break;
11685
11686 case ssiBRANG:
11687 temp_sub->d1 = itype_brang;
11688 break;
11689
11690 case ssiWAND:
11691 temp_sub->d1 = itype_wand;
11692 break;
11693
11694 case ssiRAFT:
11695 temp_sub->d1 = itype_raft;
11696 break;
11697
11698 case ssiLADDER:
11699 temp_sub->d1 = itype_ladder;
11700 break;
11701
11702 case ssiWHISTLE:
11703 temp_sub->d1 = itype_whistle;
11704 break;
11705
11706 case ssiBOOK:
11707 temp_sub->d1 = itype_book;
11708 break;
11709
11710 case ssiWALLET:
11711 temp_sub->d1 = itype_wallet;
11712 break;
11713
11714 case ssiSBOMB:
11715 temp_sub->d1 = itype_sbomb;
11716 break;
11717
11718 case ssiHCPIECE:
11719 temp_sub->d1 = itype_heartpiece;
11720 break;
11721
11722 case ssiAMULET:
11723 temp_sub->d1 = itype_amulet;
11724 break;
11725
11726 case ssiFLIPPERS:
11727 temp_sub->d1 = itype_flippers;
11728 break;
11729
11730 case ssiHOOKSHOT:
11731 temp_sub->d1 = itype_hookshot;
11732 break;
11733
11734 case ssiLENS:
11735 temp_sub->d1 = itype_lens;
11736 break;
11737
11738 case ssiHAMMER:
11739 temp_sub->d1 = itype_hammer;
11740 break;
11741
11742 case ssiBOOTS:
11743 temp_sub->d1 = itype_boots;
11744 break;
11745
11746 case ssiDIVINEFIRE:
11747 temp_sub->d1 = itype_divinefire;
11748 break;
11749
11750 case ssiDIVINEESCAPE:
11751 temp_sub->d1 = itype_divineescape;
11752 break;
11753
11754 case ssiDIVINEPROTECTION:
11755 temp_sub->d1 = itype_divineprotection;
11756 break;
11757
11758 case ssiQUIVER:
11759 temp_sub->d1 = itype_quiver;
11760 break;
11761
11762 case ssiBOMBBAG:
11763 temp_sub->d1 = itype_bombbag;
11764 break;
11765
11766 case ssiCBYRNA:
11767 temp_sub->d1 = itype_cbyrna;
11768 break;
11769
11770 case ssiROCS:
11771 temp_sub->d1 = itype_rocs;
11772 break;
11773
11774 case ssiHOVERBOOTS:
11775 temp_sub->d1 = itype_hoverboots;
11776 break;
11777
11778 case ssiSPINSCROLL:
11779 temp_sub->d1 = itype_spinscroll;
11780 break;
11781
11782 case ssiCROSSSCROLL:
11783 temp_sub->d1 = itype_crossscroll;
11784 break;
11785
11786 case ssiQUAKESCROLL:
11787 temp_sub->d1 = itype_quakescroll;
11788 break;
11789
11790 case ssiWHISPRING:
11791 temp_sub->d1 = itype_whispring;
11792 break;
11793
11794 case ssiCHARGERING:
11795 temp_sub->d1 = itype_chargering;
11796 break;
11797
11798 case ssiPERILSCROLL:
11799 temp_sub->d1 = itype_perilscroll;
11800 break;
11801
11802 case ssiWEALTHMEDAL:
11803 temp_sub->d1 = itype_wealthmedal;
11804 break;
11805
11806 case ssiHEARTRING:
11807 temp_sub->d1 = itype_heartring;
11808 break;
11809
11810 case ssiMAGICRING:
11811 temp_sub->d1 = itype_magicring;
11812 break;
11813
11814 case ssiSPINSCROLL2:
11815 temp_sub->d1 = itype_spinscroll2;
11816 break;
11817
11818 case ssiQUAKESCROLL2:
11819 temp_sub->d1 = itype_quakescroll2;
11820 break;
11821
11822 case ssiAGONY:
11823 temp_sub->d1 = itype_agony;
11824 break;
11825
11826 case ssiSTOMPBOOTS:
11827 temp_sub->d1 = itype_stompboots;
11828 break;
11829
11830 case ssiWHIMSICALRING:
11831 temp_sub->d1 = itype_whimsicalring;
11832 break;
11833
11834 case ssiPERILRING:
11835 temp_sub->d1 = itype_perilring;
11836 break;
11837
11838 default:
11839 temp_sub->d1 += itype_custom1 - ssiMAX;
11840 }
11841 }
11842
11843 //fall-through
11844 default:
11845
1/2
✓ Branch 0 taken 17970 times.
✗ Branch 1 not taken.
17970 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11846 {
11847 return qe_invalid;
11848 }
11849
11850 17970 break;
11851 }
11852
11853
2/2
✓ Branch 0 taken 11341 times.
✓ Branch 1 taken 8377 times.
19718 if(s_version < 7)
11854 {
11855
3/3
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 336 times.
8377 switch(temp_sub->type)
11856 {
11857 case ssoMAGICGAUGE:
11858 {
11859
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 192 times.
204 if(!temp_sub->d9)
11860 192 temp_sub->d9 = -1; //-1 now represents 'always'
11861 204 break;
11862 }
11863 case ssoLIFEGAUGE:
11864 336 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11865 336 break;
11866 }
11867 8377 }
11868
11869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11870 {
11871
3/3
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 17267 times.
✓ Branch 2 taken 846 times.
19718 switch(temp_sub->type)
11872 {
11873 case ssoTEXT:
11874 case ssoTEXTBOX:
11875 case ssoCURRENTITEMTEXT:
11876 case ssoCURRENTITEMCLASSTEXT:
11877
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11878
11879 1605 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11880 1605 custom_subscreen[i].objects[j].dp1 = NULL;
11881 1605 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11882 1605 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11883 1605 break;
11884
11885 case ssoCOUNTER:
11886
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(s_version<3)
11887 {
11888 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11889 temp_sub->d8=0;
11890 }
11891
11892 default:
11893 18113 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11894 18113 break;
11895 }
11896
11897 19718 strcpy(custom_subscreen[i].name, tempname);
11898 19718 custom_subscreen[i].ss_type = temp_ss;
11899 19718 }
11900 19718 }
11901
11902
2/2
✓ Branch 0 taken 3126010 times.
✓ Branch 1 taken 12288 times.
3138298 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11903 {
11904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 if(keepdata)
11905 {
11906 //clear all unused object in this subscreen -DD
11907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 switch(custom_subscreen[i].objects[j].type)
11908 {
11909 case ssoTEXT:
11910 case ssoTEXTBOX:
11911 case ssoCURRENTITEMTEXT:
11912 case ssoCURRENTITEMCLASSTEXT:
11913 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11914
11915 //fall through
11916 default:
11917 3126010 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11918 3126010 break;
11919 }
11920 3126010 }
11921 3126010 }
11922
11923 12288 return 0;
11924 12288 }
11925
11926 2048 void reset_subscreen(subscreen_group *tempss)
11927 {
11928
2/2
✓ Branch 0 taken 524288 times.
✓ Branch 1 taken 2048 times.
526336 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11929 {
11930
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 524177 times.
524288 switch(tempss->objects[i].type)
11931 {
11932 case ssoTEXT:
11933 case ssoTEXTBOX:
11934 case ssoCURRENTITEMTEXT:
11935 case ssoCURRENTITEMCLASSTEXT:
11936
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11937
11938 //fall through
11939 default:
11940 524288 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11941 524288 break;
11942 }
11943 524288 }
11944 2048 }
11945
11946 16 void reset_subscreens()
11947 {
11948
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 16 times.
2064 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11949 {
11950 2048 reset_subscreen(&custom_subscreen[i]);
11951 2048 }
11952 16 }
11953
11954 16 int32_t setupsubscreens()
11955 {
11956 16 reset_subscreens();
11957 16 int32_t tempsubscreen=zinit.subscreen;
11958 subscreen_object *tempsub;
11959
11960
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempsubscreen>=ssdtMAX)
11961 {
11962 tempsubscreen=0;
11963 }
11964
11965
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(tempsubscreen)
11966 {
11967 case ssdtOLD:
11968 case ssdtNEWSUBSCR:
11969 case ssdtREV2:
11970 case ssdtBSZELDA:
11971 case ssdtBSZELDAMODIFIED:
11972 case ssdtBSZELDAENHANCED:
11973 case ssdtBSZELDACOMPLETE:
11974 {
11975 16 tempsub = default_subscreen_active[tempsubscreen][0];
11976 int32_t i;
11977
11978
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11979 {
11980
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 992 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
11981 {
11982 case ssoTEXT:
11983 case ssoTEXTBOX:
11984 case ssoCURRENTITEMTEXT:
11985 case ssoCURRENTITEMCLASSTEXT:
11986
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11987
11988 48 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11989 48 custom_subscreen[0].objects[i].dp1 = NULL;
11990 48 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11991 48 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11992 48 break;
11993
11994 case ssoLIFEMETER:
11995 {
11996 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11997
11998 if(get_bit(deprecated_rules, 12) != 0)
11999 custom_subscreen[0].objects[i].d3=1;
12000 else
12001 custom_subscreen[0].objects[i].d3=0;
12002
12003 break;
12004 }
12005 /*
12006 case ssoTRIFRAME:
12007 {
12008 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12009 custom_subscreen[0].objects[i].d1 = 8594;
12010 custom_subscreen[0].objects[i].d2 = 8;
12011 custom_subscreen[0].objects[i].d3 = 8771;
12012 custom_subscreen[0].objects[i].d4 = 8;
12013 custom_subscreen[0].objects[i].d5 = 1;
12014 custom_subscreen[0].objects[i].d6 = 1;
12015 break;
12016 }*/
12017
12018 default:
12019 992 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12020 992 break;
12021 }
12022 1040 }
12023
12024 16 custom_subscreen[0].ss_type=sstACTIVE;
12025 16 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12026 16 tempsub = default_subscreen_active[tempsubscreen][1];
12027
12028
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12029 {
12030
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 976 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
12031 {
12032 case ssoTEXT:
12033 case ssoTEXTBOX:
12034 case ssoCURRENTITEMTEXT:
12035 case ssoCURRENTITEMCLASSTEXT:
12036
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12037
12038 64 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12039 64 custom_subscreen[1].objects[i].dp1 = NULL;
12040 64 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12041 64 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12042 64 break;
12043
12044 case ssoLIFEMETER:
12045 {
12046 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12047
12048 if(get_bit(deprecated_rules, 12) != 0)
12049 custom_subscreen[1].objects[i].d3=1;
12050 else
12051 custom_subscreen[1].objects[i].d3=0;
12052
12053 break;
12054 }
12055 /*
12056 case ssoTRIFRAME:
12057 {
12058 custom_subscreen[1].objects[i].d1 = 8594;
12059 custom_subscreen[1].objects[i].d2 = 8;
12060 custom_subscreen[1].objects[i].d3 = 8771;
12061 custom_subscreen[1].objects[i].d4 = 8;
12062 custom_subscreen[1].objects[i].d5 = 1;
12063 custom_subscreen[1].objects[i].d6 = 1;
12064 break;
12065 }*/
12066
12067 default:
12068 976 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12069 976 break;
12070 }
12071 1040 }
12072
12073 16 custom_subscreen[1].ss_type=sstACTIVE;
12074 16 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12075 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12076 16 tempsub = default_subscreen_passive[tempsubscreen][0];
12077
12078
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 16 times.
336 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12079 {
12080
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 16 times.
320 switch(tempsub[i].type)
12081 {
12082 case ssoTEXT:
12083 case ssoTEXTBOX:
12084 case ssoCURRENTITEMTEXT:
12085 case ssoCURRENTITEMCLASSTEXT:
12086
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12087
12088 48 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12089 48 custom_subscreen[2].objects[i].dp1 = NULL;
12090 48 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12091 48 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12092 48 break;
12093
12094 case ssoLIFEMETER:
12095 {
12096 16 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12097
12098
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12099 3 custom_subscreen[2].objects[i].d3=1;
12100 else
12101 13 custom_subscreen[2].objects[i].d3=0;
12102
12103 16 break;
12104 }
12105
12106 default:
12107 256 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12108 256 break;
12109 }
12110 320 }
12111
12112 16 custom_subscreen[2].ss_type=sstPASSIVE;
12113 16 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12114 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12115 16 tempsub = default_subscreen_passive[tempsubscreen][1];
12116
12117
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 304 times.
✓ Branch 3 taken 16 times.
320 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12118 {
12119
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 16 times.
304 switch(tempsub[i].type)
12120 {
12121 case ssoTEXT:
12122 case ssoTEXTBOX:
12123 case ssoCURRENTITEMTEXT:
12124 case ssoCURRENTITEMCLASSTEXT:
12125
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12126
12127 48 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12128 48 custom_subscreen[3].objects[i].dp1 = NULL;
12129 48 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12130 48 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12131 48 break;
12132
12133 case ssoLIFEMETER:
12134 {
12135 16 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12136
12137
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12138 3 custom_subscreen[3].objects[i].d3=1;
12139 else
12140 13 custom_subscreen[3].objects[i].d3=0;
12141
12142 16 break;
12143 }
12144
12145 default:
12146 240 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12147 240 break;
12148 }
12149 304 }
12150
12151 16 custom_subscreen[3].ss_type=sstPASSIVE;
12152 16 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12153 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12154 16 break;
12155 }
12156
12157 case ssdtZ3:
12158 {
12159 tempsub = z3_active_a;
12160 int32_t i;
12161
12162 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12163 {
12164 switch(tempsub[i].type)
12165 {
12166 case ssoTEXT:
12167 case ssoTEXTBOX:
12168 case ssoCURRENTITEMTEXT:
12169 case ssoCURRENTITEMCLASSTEXT:
12170 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12171
12172 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12173 custom_subscreen[0].objects[i].dp1 = NULL;
12174 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12175 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12176 break;
12177
12178 case ssoLIFEMETER:
12179 {
12180 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12181
12182 if(get_bit(deprecated_rules, 12) != 0)
12183 custom_subscreen[0].objects[i].d3=1;
12184 else
12185 custom_subscreen[0].objects[i].d3=0;
12186
12187 break;
12188 }
12189
12190 default:
12191 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12192 break;
12193 }
12194 }
12195
12196 custom_subscreen[0].ss_type=sstACTIVE;
12197 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12198 tempsub = z3_active_ab;
12199
12200 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12201 {
12202 switch(tempsub[i].type)
12203 {
12204 case ssoTEXT:
12205 case ssoTEXTBOX:
12206 case ssoCURRENTITEMTEXT:
12207 case ssoCURRENTITEMCLASSTEXT:
12208 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12209
12210 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12211 custom_subscreen[1].objects[i].dp1 = NULL;
12212 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12213 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12214 break;
12215
12216 case ssoLIFEMETER:
12217 {
12218 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12219
12220 if(get_bit(deprecated_rules, 12) != 0)
12221 custom_subscreen[1].objects[i].d3=1;
12222 else
12223 custom_subscreen[1].objects[i].d3=0;
12224
12225 break;
12226 }
12227
12228 default:
12229 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12230 break;
12231 }
12232 }
12233
12234 custom_subscreen[1].ss_type=sstACTIVE;
12235 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12236 tempsub = z3_passive_a;
12237
12238 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12239 {
12240 switch(tempsub[i].type)
12241 {
12242 case ssoTEXT:
12243 case ssoTEXTBOX:
12244 case ssoCURRENTITEMTEXT:
12245 case ssoCURRENTITEMCLASSTEXT:
12246 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12247
12248 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12249 custom_subscreen[2].objects[i].dp1 = NULL;
12250 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12251 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12252 break;
12253
12254 case ssoLIFEMETER:
12255 {
12256 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12257
12258 if(get_bit(deprecated_rules, 12) != 0)
12259 custom_subscreen[2].objects[i].d3=1;
12260 else
12261 custom_subscreen[2].objects[i].d3=0;
12262
12263 break;
12264 }
12265
12266 default:
12267 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12268 break;
12269 }
12270 }
12271
12272 custom_subscreen[2].ss_type=sstPASSIVE;
12273 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12274 tempsub = z3_passive_ab;
12275
12276 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12277 {
12278 switch(tempsub[i].type)
12279 {
12280 case ssoTEXT:
12281 case ssoTEXTBOX:
12282 case ssoCURRENTITEMTEXT:
12283 case ssoCURRENTITEMCLASSTEXT:
12284 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12285
12286 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12287 custom_subscreen[3].objects[i].dp1 = NULL;
12288 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12289 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12290 break;
12291
12292 case ssoLIFEMETER:
12293 {
12294 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12295
12296 if(get_bit(deprecated_rules, 12) != 0)
12297 custom_subscreen[3].objects[i].d3=1;
12298 else
12299 custom_subscreen[3].objects[i].d3=0;
12300
12301 break;
12302 }
12303
12304 default:
12305 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12306 break;
12307 }
12308 }
12309
12310 custom_subscreen[3].ss_type=sstPASSIVE;
12311 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12312 break;
12313 }
12314 }
12315
12316
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
80 for(int32_t i=0; i<4; ++i)
12317 {
12318 64 purge_blank_subscreen_objects(&custom_subscreen[i]);
12319 64 }
12320
12321 16 return 0;
12322 }
12323
12324 extern script_data *ffscripts[NUMSCRIPTFFC];
12325 extern script_data *itemscripts[NUMSCRIPTITEM];
12326 extern script_data *guyscripts[NUMSCRIPTGUYS];
12327 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12328 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12329 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12330 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12331 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12332 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12333 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12334 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12335 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12336 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12337 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12338
12339
12340
12341 96 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12342 {
12343 int32_t dummy;
12344 96 word s_version=0, s_cversion=0, zmeta_version=0;
12345 96 byte numscripts=0;
12346 96 numscripts=numscripts; //to avoid unused variables warnings
12347 int32_t ret;
12348
12349 //section version info
12350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
12351 {
12352 return qe_invalid;
12353 }
12354
12355 96 FFCore.quest_format[vFFScript] = s_version;
12356
12357
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
12358 {
12359 return qe_invalid;
12360 }
12361
12362
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 18)
12363 {
12364
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&zmeta_version,f,true))
12365 {
12366 return qe_invalid;
12367 }
12368 22 }
12369
12370 //al_trace("Scripts version %d\n", s_version);
12371 //section size
12372
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
12373 {
12374 return qe_invalid;
12375 }
12376
12377 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12378 96 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12379 96 temp_ffscript_version = s_version;
12380 //miscQdata *the_misc;
12381
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12382 96 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12383
12384 //finally... section data
12385
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12386 {
12387 49152 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12388
12389
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(ret != 0) return qe_invalid;
12390 49152 }
12391
12392 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12393 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12394 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12395 * there was a version bump a week before a change that broke stuff.
12396 */
12397
6/8
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 74 times.
96 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12398 {
12399 74 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12400 74 }
12401
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
96 if(s_version < 19 && keepdata)
12402 {
12403 74 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12404 74 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 1)
12407 {
12408
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12409 {
12410 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12411
12412
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12413 24576 }
12414
12415
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12416 {
12417 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12418
12419
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12420 24576 }
12421
12422
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12423 {
12424 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12427 24576 }
12428
12429
12430
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12431 {
12432 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12433
12434
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12435 24576 }
12436
12437
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 16)
12438 {
12439
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
198 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12440 {
12441 176 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12442
12443
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(ret != 0) return qe_invalid;
12444 176 }
12445 22 }
12446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 else if(s_version > 13)
12447 {
12448 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12449 {
12450 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12451
12452 if(ret != 0) return qe_invalid;
12453 }
12454
12455 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12456 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12457
12458 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12459 }
12460
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 else if(s_version > 4)
12461 {
12462
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12463 {
12464 296 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12465
12466
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(ret != 0) return qe_invalid;
12467 296 }
12468
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12470
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12471
12472
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12473
12474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12475
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12476
12477
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12478
12479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12480
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_F6];
12481
12482
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12483
12484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12485
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12486
12487
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12488 74 }
12489 else
12490 {
12491 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12492 {
12493 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12494
12495 if(ret != 0) return qe_invalid;
12496 }
12497
12498 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12499 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12500
12501 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12502
12503 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12504 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12505
12506 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12507
12508 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12509 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12510
12511 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12512
12513 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12514 delete globalscripts[GLOBAL_SCRIPT_F6];
12515
12516 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12517
12518 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12519 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12520
12521 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12522 }
12523
12524
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 10) //expanded the number of Player scripts to 5.
12525 {
12526
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 22 times.
132 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12527 {
12528 110 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12529
12530
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(ret != 0) return qe_invalid;
12531 110 }
12532 22 }
12533 else
12534 {
12535
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12536 {
12537 222 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12538
12539
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(ret != 0) return qe_invalid;
12540 222 }
12541
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[3] != NULL)
12542
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete playerscripts[3];
12543
12544
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[3] = new script_data();
12545
12546
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[4] != NULL)
12547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 delete playerscripts[4];
12548
12549
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[4] = new script_data();
12550 }
12551
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
96 if(s_version > 8 && s_version < 10)
12552 {
12553
12554 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12555 {
12556 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12557
12558 if(ret != 0) return qe_invalid;
12559 }
12560 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12561 {
12562 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12563
12564 if(ret != 0) return qe_invalid;
12565 }
12566
12567 }
12568
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 10)
12569 {
12570
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12571 {
12572 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12573
12574
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12575 5632 }
12576
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12577 {
12578 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12579
12580
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12581 5632 }
12582
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12583 {
12584 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12585
12586
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12587 5632 }
12588
12589 22 }
12590
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=12)
12591 {
12592
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12593 {
12594 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12595
12596
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12597 5632 }
12598 22 }
12599
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=15)
12600 {
12601
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12602 {
12603 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12604
12605
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12606 11264 }
12607 22 }
12608
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >19)
12609 {
12610 22 word numgenscripts = NUMSCRIPTSGENERIC;
12611
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&numgenscripts,f,true))
12612 {
12613 return qe_invalid;
12614 }
12615
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < numgenscripts; i++)
12616 {
12617 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12618
12619
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12620 11264 }
12621 22 }
12622
12623 /*
12624 else //Is this trip really necessary?
12625 {
12626 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12627 {
12628
12629 ewpnscripts[i] = NULL;
12630 }
12631 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12632 {
12633 dmapscripts[i] = NULL;
12634 }
12635 }
12636 */
12637
12638 96 }
12639
12640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 2)
12641 {
12642 int32_t bufsize;
12643 96 p_igetl(&bufsize, f, true);
12644 96 char * buf = new char[bufsize+1];
12645 96 pfread(buf, bufsize, f, true);
12646 96 buf[bufsize]=0;
12647
12648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
12649
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 zScript = string(buf);
12650
12651
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 delete[] buf;
12652 word numffcbindings;
12653 96 p_igetw(&numffcbindings, f, true);
12654
12655
2/2
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 96 times.
1066 for(int32_t i=0; i<numffcbindings; i++)
12656 {
12657 word id;
12658 970 p_igetw(&id, f, true);
12659 970 p_igetl(&bufsize, f, true);
12660 970 buf = new char[bufsize+1];
12661 970 pfread(buf, bufsize, f, true);
12662 970 buf[bufsize]=0;
12663
12664 //fix for buggy older saved quests -DD
12665
2/4
✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 970 times.
970 if(keepdata && id < NUMSCRIPTFFC-1)
12666 970 ffcmap[id].scriptname = buf;
12667
12668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 delete[] buf;
12669 970 }
12670
12671 word numglobalbindings;
12672 96 p_igetw(&numglobalbindings, f, true);
12673
12674
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 96 times.
494 for(int32_t i=0; i<numglobalbindings; i++)
12675 {
12676 word id;
12677 398 p_igetw(&id, f, true);
12678 398 p_igetl(&bufsize, f, true);
12679 398 buf = new char[bufsize+1];
12680 398 pfread(buf, bufsize, f, true);
12681 398 buf[bufsize]=0;
12682
12683 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12684 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12685 // Ignore these. -DD
12686
4/6
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 239 times.
398 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12687 {
12688 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12689
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if(strcmp(buf,"~Continue") == 0)
12690 {
12691 globalmap[id].scriptname = "";
12692
12693 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12694 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12695 }
12696 else
12697 {
12698 239 globalmap[id].scriptname = buf;
12699 }
12700 239 }
12701
12702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12703 398 }
12704
12705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 3)
12706 {
12707 word numitembindings;
12708 96 p_igetw(&numitembindings, f, true);
12709
12710
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 96 times.
177 for(int32_t i=0; i<numitembindings; i++)
12711 {
12712 word id;
12713 81 p_igetw(&id, f, true);
12714 81 p_igetl(&bufsize, f, true);
12715 81 buf = new char[bufsize+1];
12716 81 pfread(buf, bufsize, f, true);
12717 81 buf[bufsize]=0;
12718
12719 //fix this too
12720
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && id <NUMSCRIPTITEM-1)
12721 81 itemmap[id].scriptname = buf;
12722
12723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 delete[] buf;
12724 81 }
12725 96 }
12726 //(v9+)
12727
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 8)
12728 {
12729 //npc scripts
12730 word numnpcbindings;
12731 22 p_igetw(&numnpcbindings, f, true);
12732
12733
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 22 times.
34 for(int32_t i=0; i<numnpcbindings; i++)
12734 {
12735 word id;
12736 12 p_igetw(&id, f, true);
12737 12 p_igetl(&bufsize, f, true);
12738 12 buf = new char[bufsize+1];
12739 12 pfread(buf, bufsize, f, true);
12740 12 buf[bufsize]=0;
12741
12742 //fix this too
12743
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12744 12 npcmap[id].scriptname = buf;
12745
12746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12747 12 }
12748 //lweapon
12749 word numlwpnbindings;
12750 22 p_igetw(&numlwpnbindings, f, true);
12751
12752
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 22 times.
64 for(int32_t i=0; i<numlwpnbindings; i++)
12753 {
12754 word id;
12755 42 p_igetw(&id, f, true);
12756 42 p_igetl(&bufsize, f, true);
12757 42 buf = new char[bufsize+1];
12758 42 pfread(buf, bufsize, f, true);
12759 42 buf[bufsize]=0;
12760
12761 //fix this too
12762
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12763 42 lwpnmap[id].scriptname = buf;
12764
12765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12766 42 }
12767 //eweapon
12768 word numewpnbindings;
12769 22 p_igetw(&numewpnbindings, f, true);
12770
12771
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 22 times.
85 for(int32_t i=0; i<numewpnbindings; i++)
12772 {
12773 word id;
12774 63 p_igetw(&id, f, true);
12775 63 p_igetl(&bufsize, f, true);
12776 63 buf = new char[bufsize+1];
12777 63 pfread(buf, bufsize, f, true);
12778 63 buf[bufsize]=0;
12779
12780 //fix this too
12781
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12782 63 ewpnmap[id].scriptname = buf;
12783
12784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12785 63 }
12786 //hero
12787 word numherobindings;
12788 22 p_igetw(&numherobindings, f, true);
12789
12790
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22 times.
26 for(int32_t i=0; i<numherobindings; i++)
12791 {
12792 word id;
12793 4 p_igetw(&id, f, true);
12794 4 p_igetl(&bufsize, f, true);
12795 4 buf = new char[bufsize+1];
12796 4 pfread(buf, bufsize, f, true);
12797 4 buf[bufsize]=0;
12798
12799 //fix this too
12800
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12801 4 playermap[id].scriptname = buf;
12802
12803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12804 4 }
12805 //dmaps
12806 word numdmapbindings;
12807 22 p_igetw(&numdmapbindings, f, true);
12808
12809
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numdmapbindings; i++)
12810 {
12811 word id;
12812 14 p_igetw(&id, f, true);
12813 14 p_igetl(&bufsize, f, true);
12814 14 buf = new char[bufsize+1];
12815 14 pfread(buf, bufsize, f, true);
12816 14 buf[bufsize]=0;
12817
12818 //fix this too
12819
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12820 14 dmapmap[id].scriptname = buf;
12821
12822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12823 14 }
12824 //screen
12825 word numscreenbindings;
12826 22 p_igetw(&numscreenbindings, f, true);
12827
12828
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 22 times.
33 for(int32_t i=0; i<numscreenbindings; i++)
12829 {
12830 word id;
12831 11 p_igetw(&id, f, true);
12832 11 p_igetl(&bufsize, f, true);
12833 11 buf = new char[bufsize+1];
12834 11 pfread(buf, bufsize, f, true);
12835 11 buf[bufsize]=0;
12836
12837 //fix this too
12838
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12839 11 screenmap[id].scriptname = buf;
12840
12841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12842 11 }
12843 22 }
12844
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 11)
12845 {
12846 word numspritebindings;
12847 22 p_igetw(&numspritebindings, f, true);
12848
12849
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 22 times.
32 for(int32_t i=0; i<numspritebindings; i++)
12850 {
12851 word id;
12852 10 p_igetw(&id, f, true);
12853 10 p_igetl(&bufsize, f, true);
12854 10 buf = new char[bufsize+1];
12855 10 pfread(buf, bufsize, f, true);
12856 10 buf[bufsize]=0;
12857
12858 //fix this too
12859
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
12860 10 itemspritemap[id].scriptname = buf;
12861
12862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12863 10 }
12864 22 }
12865
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 15)
12866 {
12867 word numcombobindings;
12868 22 p_igetw(&numcombobindings, f, true);
12869
12870
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 22 times.
46 for(int32_t i=0; i<numcombobindings; i++)
12871 {
12872 word id;
12873 24 p_igetw(&id, f, true);
12874 24 p_igetl(&bufsize, f, true);
12875 24 buf = new char[bufsize+1];
12876 24 pfread(buf, bufsize, f, true);
12877 24 buf[bufsize]=0;
12878
12879 //fix this too
12880
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12881 24 comboscriptmap[id].scriptname = buf;
12882
12883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
12884 24 }
12885 22 }
12886
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 19)
12887 {
12888 word numgenericbindings;
12889 22 p_igetw(&numgenericbindings, f, true);
12890
12891
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numgenericbindings; i++)
12892 {
12893 word id;
12894 14 p_igetw(&id, f, true);
12895 14 p_igetl(&bufsize, f, true);
12896 14 buf = new char[bufsize+1];
12897 14 pfread(buf, bufsize, f, true);
12898 14 buf[bufsize]=0;
12899
12900 //fix this too
12901
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12902 14 genericmap[id].scriptname = buf;
12903
12904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12905 14 }
12906 22 }
12907 96 }
12908
12909 96 return 0;
12910 96 }
12911
12912 99 void reset_scripts()
12913 {
12914 //OK, who spaced this? ;)
12915
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12916 {
12917
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(ffscripts[i]!=NULL) delete ffscripts[i];
12918 50688 }
12919
12920
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12921 {
12922
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemscripts[i]!=NULL) delete itemscripts[i];
12923 25344 }
12924
12925
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12926 {
12927
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(guyscripts[i]!=NULL) delete guyscripts[i];
12928 25344 }
12929
12930
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12931 {
12932
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12933 25344 }
12934
12935
12936
12937
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12938 {
12939
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(screenscripts[i]!=NULL) delete screenscripts[i];
12940 25344 }
12941
12942
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12943 {
12944
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 792 times.
792 if(globalscripts[i]!=NULL) delete globalscripts[i];
12945 792 }
12946
12947
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12948 {
12949
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 495 times.
495 if(playerscripts[i]!=NULL) delete playerscripts[i];
12950 495 }
12951
12952
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12953 {
12954
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12955 25344 }
12956
12957
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12958 {
12959
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12960 25344 }
12961
12962
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12963 {
12964
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12965 25344 }
12966
12967
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12968 {
12969
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12970 25344 }
12971
12972
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12973 {
12974
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(comboscripts[i]!=NULL) delete comboscripts[i];
12975 50688 }
12976
12977 99 next_script_data_debug_id = 0;
12978
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12979 {
12980
3/4
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 35840 times.
✓ Branch 2 taken 35840 times.
✗ Branch 3 not taken.
50688 if(genericscripts[i]!=NULL) delete genericscripts[i];
12981
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 genericscripts[i] = new script_data();
12982 50688 }
12983
12984
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12985 {
12986
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 ffscripts[i] = new script_data();
12987 50688 }
12988
12989
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12990 {
12991
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemscripts[i] = new script_data();
12992 25344 }
12993
12994
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12995 {
12996
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 guyscripts[i] = new script_data();
12997 25344 }
12998
12999
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13000 {
13001
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 wpnscripts[i] = new script_data();
13002 25344 }
13003
13004
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13005 {
13006
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 screenscripts[i] = new script_data();
13007 25344 }
13008
13009
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13010 {
13011
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 globalscripts[i] = new script_data();
13012 792 }
13013
13014
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13015 {
13016
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 playerscripts[i] = new script_data();
13017 495 }
13018
13019
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13020 {
13021
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 lwpnscripts[i] = new script_data();
13022 25344 }
13023
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13024 {
13025
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 ewpnscripts[i] = new script_data();
13026 25344 }
13027
13028
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13029 {
13030
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 dmapscripts[i] = new script_data();
13031 25344 }
13032
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13033 {
13034
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemspritescripts[i] = new script_data();
13035 25344 }
13036
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13037 {
13038
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 comboscripts[i] = new script_data();
13039 50688 }
13040 99 }
13041
13042 extern script_command command_list[];
13043 193316 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13044 {
13045 //Please also update loadquest() when modifying this method -DD
13046 193316 char b33[34] = {0};
13047 193316 b33[33] = 0;
13048 193316 ffscript temp_script;
13049 193316 int32_t num_commands=1000;
13050
13051
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(s_version>=2)
13052 {
13053
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 if(!p_igetl(&num_commands,f,true))
13054 {
13055 return qe_invalid;
13056 }
13057 193316 }
13058
13059
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13060 {
13061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 delete (*script);
13063
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 (*script) = new script_data(num_commands);
13064 193316 }
13065
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 114182 times.
193316 if(s_version >= 16)
13066 {
13067
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 zasm_meta temp_meta;
13068
13069
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13070 {
13071 return qe_invalid;
13072 }
13073
13074
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.meta_v),f,true))
13075 {
13076 return qe_invalid;
13077 }
13078
13079
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13080 {
13081 return qe_invalid;
13082 }
13083
13084
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.script_type),f,true))
13085 {
13086 return qe_invalid;
13087 }
13088
13089
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(int32_t q = 0; q < 8; ++q)
13090 {
13091
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 431640 times.
633072 if(zmeta_version < 3)
13092 {
13093
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 6647256 times.
6848688 for(int32_t c = 0; c < 33; ++c)
13094 {
13095
2/4
✓ Branch 0 taken 6647256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6647256 times.
✗ Branch 3 not taken.
6647256 if(!p_getc(&(b33[c]),f,true))
13096 {
13097 return qe_invalid;
13098 }
13099 6647256 }
13100
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.run_idens[q].assign(b33);
13101 201432 }
13102 else
13103 {
13104
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13105 {
13106 return qe_invalid;
13107 }
13108 }
13109 633072 }
13110
13111
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 633072 times.
712206 for(int32_t q = 0; q < 8; ++q)
13112 {
13113
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13114 {
13115 return qe_invalid;
13116 }
13117 633072 }
13118
13119
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.flags),f,true))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13130 {
13131 return qe_invalid;
13132 }
13133
13134
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13135 {
13136 return qe_invalid;
13137 }
13138
13139
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13140 {
13141 return qe_invalid;
13142 }
13143
13144
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 53955 times.
79134 if(zmeta_version == 2)
13145 {
13146
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13147 {
13148
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13149 {
13150 return qe_invalid;
13151 }
13152 830907 }
13153
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.script_name.assign(b33);
13154
13155
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13156 {
13157
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13158 {
13159 return qe_invalid;
13160 }
13161 830907 }
13162
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.author.assign(b33);
13163 25179 }
13164
1/2
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
53955 else if(zmeta_version > 2)
13165 {
13166
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.script_name,f,true))
13167 return qe_invalid;
13168
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.author,f,true))
13169 return qe_invalid;
13170 53955 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13171
2/2
✓ Branch 0 taken 539550 times.
✓ Branch 1 taken 53955 times.
593505 for(auto q = 0; q < num_meta_attrib; ++q)
13172 {
13173
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13174 return qe_invalid;
13175
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13176 return qe_invalid;
13177 539550 }
13178
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13179 {
13180
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13181 return qe_invalid;
13182
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13183 return qe_invalid;
13184 431640 }
13185
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13186 {
13187
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13188 return qe_invalid;
13189
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13190 return qe_invalid;
13191 431640 }
13192
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 53955 times.
917235 for(auto q = 0; q < 16; ++q)
13193 {
13194
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13195 return qe_invalid;
13196
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13197 return qe_invalid;
13198 863280 }
13199 53955 }
13200
2/2
✓ Branch 0 taken 53955 times.
✓ Branch 1 taken 25179 times.
79134 if(zmeta_version > 3)
13201 {
13202
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13203 {
13204
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.initd[q],f,true))
13205 return qe_invalid;
13206
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13207 return qe_invalid;
13208 431640 }
13209
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getc(&temp_meta.initd_type[q],f,true))
13212 return qe_invalid;
13213 431640 }
13214 53955 }
13215 else
13216 {
13217
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 25179 times.
226611 for(auto q = 0; q < 8; ++q)
13218 {
13219
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.initd[q] = temp_meta.run_idens[q];
13220 201432 }
13221 }
13222
13223
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 if(keepdata)
13224
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 (*script)->meta = temp_meta;
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79134 times.
79134 }
13226
13227
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 temp_script.clear();
13228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7767709 times.
7767709 for(int32_t j=0; j<num_commands; j++)
13229 {
13230
2/4
✓ Branch 0 taken 7767709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7767709 times.
✗ Branch 3 not taken.
7767709 if(!p_igetw(&(temp_script.command),f,true))
13231 {
13232 return qe_invalid;
13233 }
13234
13235
2/2
✓ Branch 0 taken 7574393 times.
✓ Branch 1 taken 193316 times.
7767709 if(temp_script.command == 0xFFFF)
13236 {
13237
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13238
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 (*script)->zasm[j].clear();
13239 193316 break;
13240 }
13241 else
13242 {
13243
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13244 {
13245 return qe_invalid;
13246 }
13247
13248
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13249 {
13250 return qe_invalid;
13251 }
13252
13253
2/2
✓ Branch 0 taken 451725 times.
✓ Branch 1 taken 7122668 times.
7574393 if(s_version >= 21)
13254 {
13255 451725 uint32_t sz = 0;
13256
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13257 {
13258 return qe_invalid;
13259 }
13260
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450203 times.
451725 if(sz) //string found
13261 {
13262
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13263 char dummy;
13264
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13265 {
13266
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13267 {
13268 return qe_invalid;
13269 }
13270
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13271 115152 }
13272 1522 }
13273
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13274 {
13275 return qe_invalid;
13276 }
13277
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451635 times.
451725 if(sz) //vector found
13278 {
13279
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13280 int32_t dummy;
13281
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13282 {
13283
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13284 {
13285 return qe_invalid;
13286 }
13287
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13288 1311 }
13289 90 }
13290 451725 }
13291
13292
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 if(keepdata)
13293 {
13294
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.give((*script)->zasm[j]);
13295 7574393 }
13296 }
13297
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.clear();
13298 7574393 }
13299
13300 193316 return 0;
13301 193316 }
13302
13303 extern SAMPLE customsfxdata[WAV_COUNT];
13304 extern uint8_t customsfxflag[WAV_COUNT>>3];
13305 extern int32_t sfxdat;
13306 extern DATAFILE *sfxdata;
13307 const char *old_sfx_string[Z35] =
13308 {
13309 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13310 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13311 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13312 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13313 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13314 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13315 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13316 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13317 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13318 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13319 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13320 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13321 };
13322 char *sfx_string[WAV_COUNT];
13323
13324 96 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13325 {
13326 //these are here to bypass compiler warnings about unused arguments
13327 96 Header=Header;
13328
13329 int32_t dummy;
13330 96 word s_version=0, s_cversion=0;
13331 //int32_t ret;
13332 SAMPLE temp_sample;
13333 96 temp_sample.loop_start=0;
13334 96 temp_sample.loop_end=0;
13335 96 temp_sample.param=0;
13336
13337 //section version info
13338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
13339 {
13340 return qe_invalid;
13341 }
13342
13343 96 FFCore.quest_format[vSFX] = s_version;
13344
13345 //al_trace("SFX version %d\n", s_version);
13346
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
13347 {
13348 return qe_invalid;
13349 }
13350
13351 //section size
13352
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
13353 {
13354 return qe_invalid;
13355 }
13356
13357 /* HIGHLY UNORTHODOX UPDATING THING, by L
13358 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13359 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13360 * changing from 1 to 2.
13361 */
13362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(s_version < 2 && keepdata)
13363 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13364
13365 /* End highly unorthodox updating thing */
13366
13367 96 int32_t wavcount = WAV_COUNT;
13368
13369
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13370 wavcount = 128;
13371
13372 uint8_t tempflag[WAV_COUNT>>3];
13373
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 4)
13375 {
13376 memset(tempflag, 0xFF, WAV_COUNT>>3);
13377 }
13378 else
13379 {
13380
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13381 memset(tempflag, 0, WAV_COUNT>>3);
13382
13383
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 96 times.
3168 for(int32_t i=0; i<(wavcount>>3); i++)
13384 {
13385 3072 p_getc(&tempflag[i], f, true);
13386 3072 }
13387
13388 }
13389
13390
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version>4)
13391 {
13392
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<WAV_COUNT; i++)
13393 {
13394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(keepdata)
13395 {
13396 24480 sprintf(sfx_string[i],"s%03d",i);
13397
13398
2/2
✓ Branch 0 taken 18720 times.
✓ Branch 1 taken 5760 times.
24480 if((i<Z35))
13399 5760 strcpy(sfx_string[i], old_sfx_string[i-1]);
13400 24480 }
13401
13402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(i>=wavcount)
13403 continue;
13404
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13405 {
13406 char tempname[36];
13407
13408
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!pfread(tempname, 36, f, keepdata))
13409 {
13410 return qe_invalid;
13411 }
13412
13413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(keepdata)
13414 {
13415 1835 strcpy(sfx_string[i], tempname);
13416 1835 sfx_string[i][35] = 0; //Force NULL Termination
13417 1835 }
13418 1835 }
13419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22645 times.
22645 else if(keepdata)
13420 {
13421 22645 sprintf(sfx_string[i],"s%03d",i);
13422
13423
2/2
✓ Branch 0 taken 18224 times.
✓ Branch 1 taken 4421 times.
22645 if(i<Z35)
13424 4421 strcpy(sfx_string[i], old_sfx_string[i-1]);
13425 22645 sfx_string[i][35] = 0; //Force NULL Termination
13426 22645 }
13427 24480 }
13428 96 }
13429 else
13430 {
13431 if(keepdata)
13432 {
13433 for(int32_t i=1; i<WAV_COUNT; i++)
13434 {
13435 sprintf(sfx_string[i],"s%03d",i);
13436
13437 if(i<Z35)
13438 strcpy(sfx_string[i], old_sfx_string[i-1]);
13439 }
13440 }
13441 }
13442
13443 //finally... section data
13444
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<wavcount; i++)
13445 {
13446
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13447 {
13448
13449
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13450 {
13451 return qe_invalid;
13452 }
13453
13454 1835 (temp_sample.bits) = dummy;
13455
13456
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13457 {
13458 return qe_invalid;
13459 }
13460
13461 1835 (temp_sample.stereo) = dummy;
13462
13463
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13464 {
13465 return qe_invalid;
13466 }
13467
13468 1835 (temp_sample.freq) = dummy;
13469
13470
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13471 {
13472 return qe_invalid;
13473 }
13474
13475 1835 (temp_sample.priority) = dummy;
13476
13477
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.len),f,true))
13478 {
13479 return qe_invalid;
13480 }
13481
13482
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13483 {
13484 return qe_invalid;
13485 }
13486
13487
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13488 {
13489 return qe_invalid;
13490 }
13491
13492
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.param),f,keepdata))
13493 {
13494 return qe_invalid;
13495 }
13496
13497 // al_trace("F%i: L%i\n",i,temp_sample.len);
13498 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13499 1835 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13500 1835 temp_sample.data = calloc(len,1);
13501
13502
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(s_version < 3)
13503 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13504
13505 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(s_version < 2)
13507 {
13508 if(!pfread(temp_sample.data, len,f,keepdata))
13509 {
13510 return qe_invalid;
13511 }
13512 }
13513 else
13514 {
13515 //re-endianfy the data
13516 1835 int32_t wordstoread = len / sizeof(word);
13517
13518
2/2
✓ Branch 0 taken 53693862 times.
✓ Branch 1 taken 1835 times.
53695697 for(int32_t j=0; j<wordstoread; j++)
13519 {
13520 word temp;
13521
13522
1/2
✓ Branch 0 taken 53693862 times.
✗ Branch 1 not taken.
53693862 if(!p_igetw(&temp, f, keepdata))
13523 {
13524 return qe_invalid;
13525 }
13526
13527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53693862 times.
53693862 if(keepdata)
13528 53693862 ((word *)temp_sample.data)[j] = temp;
13529 53693862 }
13530 }
13531 1835 }
13532
2/2
✓ Branch 0 taken 4421 times.
✓ Branch 1 taken 18224 times.
22645 else if(i < Z35)
13533 {
13534 4421 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13535 4421 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13536 4421 set_bit(tempflag, i-1, 1);
13537 4421 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13538 4421 temp_sample.data = calloc(len,1);
13539 4421 memcpy(temp_sample.data, datsamp->data, len);
13540 4421 }
13541 18224 else continue;
13542
13543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(keepdata)
13544 {
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(customsfxdata[i].data!=NULL)
13546 {
13547 // delete [] customsfxdata[i].data;
13548 6256 free(customsfxdata[i].data);
13549 6256 }
13550
13551 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13552 6256 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13553 6256 customsfxdata[i].data = calloc(len2,1);
13554 6256 customsfxdata[i].bits = temp_sample.bits;
13555 6256 customsfxdata[i].stereo = temp_sample.stereo;
13556 6256 customsfxdata[i].freq = temp_sample.freq;
13557 6256 customsfxdata[i].priority = temp_sample.priority;
13558 6256 customsfxdata[i].len = temp_sample.len;
13559 6256 customsfxdata[i].loop_start = temp_sample.loop_start;
13560 6256 customsfxdata[i].loop_end = temp_sample.loop_end;
13561 6256 customsfxdata[i].param = temp_sample.param;
13562 6256 int32_t cpylen = len2;
13563
13564
1/2
✓ Branch 0 taken 6256 times.
✗ Branch 1 not taken.
6256 if(s_version<3)
13565 {
13566 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13567 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13568 }
13569
13570 6256 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13571 6256 }
13572
13573 6256 free(temp_sample.data);
13574 6256 }
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
13577 96 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13578
13579 96 sfxdat=0;
13580 96 return 0;
13581 96 }
13582
13583 99 void setupsfx()
13584 {
13585
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<WAV_COUNT; i++)
13586 {
13587 25245 sprintf(sfx_string[i],"s%03d",i);
13588
13589
2/2
✓ Branch 0 taken 19305 times.
✓ Branch 1 taken 5940 times.
25245 if(i<Z35)
13590 {
13591 5940 strcpy(sfx_string[i], old_sfx_string[i-1]);
13592 5940 }
13593
13594 25245 memset(customsfxflag, 0, WAV_COUNT>>3);
13595
13596 25245 int32_t j=i;
13597
13598
2/2
✓ Branch 0 taken 6039 times.
✓ Branch 1 taken 19206 times.
25245 if(i>Z35)
13599 {
13600 19206 i=Z35;
13601 19206 }
13602
13603 25245 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13604
13605
2/2
✓ Branch 0 taken 7395 times.
✓ Branch 1 taken 17850 times.
25245 if(customsfxdata[j].data!=NULL)
13606 {
13607 // delete [] customsfxdata[j].data;
13608 17850 free(customsfxdata[j].data);
13609 17850 }
13610
13611 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13612 25245 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13613 25245 customsfxdata[j].bits = temp_sample->bits;
13614 25245 customsfxdata[j].stereo = temp_sample->stereo;
13615 25245 customsfxdata[j].freq = temp_sample->freq;
13616 25245 customsfxdata[j].priority = temp_sample->priority;
13617 25245 customsfxdata[j].len = temp_sample->len;
13618 25245 customsfxdata[j].loop_start = temp_sample->loop_start;
13619 25245 customsfxdata[j].loop_end = temp_sample->loop_end;
13620 25245 customsfxdata[j].param = temp_sample->param;
13621 25245 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13622 25245 i=j;
13623 25245 }
13624 99 }
13625
13626 extern char *guy_string[eMAXGUYS];
13627 extern const char *old_guy_string[OLDMAXGUYS];
13628
13629 99 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13630 {
13631 dword dummy;
13632 word guy_cversion;
13633 99 word guyversion=0;
13634
13635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version >= 0x193)
13636 {
13637 //section version info
13638
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guyversion,f,true))
13639 {
13640 return qe_invalid;
13641 }
13642
13643 99 FFCore.quest_format[vGuys] = guyversion;
13644
13645 //al_trace("Guys version %d\n", guyversion);
13646
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guy_cversion,f,true))
13647 {
13648 return qe_invalid;
13649 }
13650 99 al_trace("Guy CVersion is: %d\n", guy_cversion);
13651 //section size
13652
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
13653 {
13654 return qe_invalid;
13655 }
13656 99 }
13657
13658
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(guyversion > 3)
13659 {
13660
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13661 {
13662 char tempname[64];
13663
13664 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13665 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13666
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49152 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13667 {
13668 memset(tempname, 0, sizeof(char)*64);
13669 sprintf(tempname, "e%03d", i);
13670 strcpy(guy_string[i], tempname);
13671
13672 continue;
13673 }
13674
13675
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(tempname, 64, f, keepdata))
13676 {
13677 return qe_invalid;
13678 }
13679
13680 // Don't retain names of uneditable enemy entries!
13681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
13682 {
13683 // for version upgrade to 2.5
13684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && i >= 177)
13685 {
13686 // some of the older builds have names such as 'zz123',
13687 // (this order gets messed up with some eXXX and some zzXXX)
13688 // so let's update to the newer naming convection. -Gleeok
13689 char tmpbuf[64];
13690 memset(tmpbuf, 0, sizeof(char)*64);
13691 sprintf(tmpbuf, "zz%03d", i);
13692
13693 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13694 {
13695 memset(tempname, 0, sizeof(char)*64);
13696 sprintf(tempname, "e%03d", i);
13697 }
13698 }
13699
13700
6/6
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 32160 times.
✓ Branch 2 taken 16128 times.
✓ Branch 3 taken 864 times.
✓ Branch 4 taken 13280 times.
✓ Branch 5 taken 2848 times.
49152 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13701 {
13702 46304 strcpy(guy_string[i], tempname);
13703 46304 }
13704 else
13705 {
13706 2848 strcpy(guy_string[i],old_guy_string[i]);
13707 }
13708 49152 }
13709 49152 }
13710 96 }
13711 else
13712 {
13713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
13714 {
13715
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i=0; i<eMAXGUYS; i++)
13716 {
13717 1536 sprintf(guy_string[i],"zz%03d",i);
13718 1536 }
13719
13720
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3 times.
534 for(int32_t i=0; i<OLDMAXGUYS; i++)
13721 {
13722 531 strcpy(guy_string[i],old_guy_string[i]);
13723 531 }
13724 3 }
13725 }
13726
13727
13728 //finally... section data
13729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
13730 {
13731 99 init_guys(guyversion); //using default data for now...
13732
13733 // Goriya guy fix
13734
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13735 {
13736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13737 {
13738 3 guysbuf[gGORIYA].tile=130;
13739 3 guysbuf[gGORIYA].e_tile=130;
13740 3 }
13741 3 }
13742 99 }
13743
13744
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
13745 {
13746 if(get_bit(deprecated_rules,46))
13747 {
13748 guysbuf[eDODONGO].cset=14;
13749 guysbuf[eDODONGO].bosspal=spDIG;
13750 }
13751 }
13752 // Not sure when this first changed, but it's necessary for 2.10, at least
13753 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13754 //2.10 Fixes
13755
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13756 {
13757 3 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13758 3 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13759 3 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13760 3 guysbuf[eCENT1].misc3 = 1;
13761 3 guysbuf[eCENT2].misc3 = 1;
13762 3 }
13763
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13764 {
13765 99 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13766 99 }
13767
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version <= 0x210)
13768 {
13769 3 guysbuf[eGLEEOK1F].misc6 = 16;
13770 3 guysbuf[eGLEEOK2F].misc6 = 16;
13771 3 guysbuf[eGLEEOK3F].misc6 = 16;
13772 3 guysbuf[eGLEEOK4F].misc6 = 16;
13773
13774 3 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13775 3 guysbuf[eBATROBE].misc4 = 1;
13776 //guysbuf[eSUMMONER].misc4 = 1;
13777 3 guysbuf[eWWIZ].misc4 = 1;
13778 3 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13779 3 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13780 3 }
13781
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version == 0x190)
13782 {
13783 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13784 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13785 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13786 }
13787
13788 // The versions here may not be correct
13789 // zelda_version>=0x211 handled at guyversion<24
13790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version <= 0x190)
13791 {
13792 guysbuf[eCENT1].misc3 = 0;
13793 guysbuf[eCENT2].misc3 = 0;
13794 guysbuf[eMOLDORM].misc2 = 0;
13795 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13796 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13797 }
13798
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 else if(Header->zelda_version <= 0x210)
13799 {
13800 3 guysbuf[eCENT1].misc3 = 1;
13801 3 guysbuf[eCENT2].misc3 = 1;
13802 3 guysbuf[eMOLDORM].misc2 = 0;
13803 3 }
13804
13805
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13806 {
13807 3 guysbuf[eKEESE1].misc16 = 120;
13808 3 guysbuf[eKEESE2].misc16 = 120;
13809 3 guysbuf[eKEESE3].misc16 = 120;
13810 3 guysbuf[eKEESETRIB].misc16 = 120;
13811 3 guysbuf[eKEESE1].misc17 = 16;
13812 3 guysbuf[eKEESE2].misc17 = 16;
13813 3 guysbuf[eKEESE3].misc17 = 16;
13814 3 guysbuf[eKEESETRIB].misc17 = 16;
13815
13816 3 guysbuf[ePEAHAT].misc16 = 80;
13817 3 guysbuf[ePEAHAT].misc17 = 16;
13818
13819 3 guysbuf[eGHINI2].misc16 = 120;
13820 3 guysbuf[eGHINI2].misc17 = 10;
13821
13822 3 }
13823
13824
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(guyversion<=2)
13825 {
13826 3 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13827 }
13828
13829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(guyversion > 3)
13830 {
13831 guydata tempguy;
13832
13833
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13834 {
13835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13836 {
13837 if(i >= OLDBETAMAXGUYS)
13838 {
13839 memset(&guysbuf[i], 0, sizeof(guydata));
13840 continue;
13841 }
13842 }
13843
13844 49152 memset(&tempguy, 0, sizeof(guydata));
13845
13846
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags),f,keepdata))
13847 {
13848 return qe_invalid;
13849 }
13850
13851
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13852 {
13853 return qe_invalid;
13854 }
13855
13856
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13857 {
13858
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tile),f,keepdata))
13859 {
13860 return qe_invalid;
13861 }
13862 11264 }
13863 else
13864 {
13865
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.tile),f,keepdata))
13866 {
13867 return qe_invalid;
13868 }
13869 }
13870
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.width),f,keepdata))
13871 {
13872 return qe_invalid;
13873 }
13874
13875
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.height),f,keepdata))
13876 {
13877 return qe_invalid;
13878 }
13879
13880
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13881 {
13882
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13883 {
13884 return qe_invalid;
13885 }
13886 11264 }
13887 else
13888 {
13889
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13890 {
13891 return qe_invalid;
13892 }
13893 }
13894
13895
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_width),f,keepdata))
13896 {
13897 return qe_invalid;
13898 }
13899
13900
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_height),f,keepdata))
13901 {
13902 return qe_invalid;
13903 }
13904
13905
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13906 {
13907
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13908 {
13909 return qe_invalid;
13910 }
13911 11264 }
13912 else
13913 {
13914
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13915 {
13916 return qe_invalid;
13917 }
13918 }
13919
13920
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_width),f,keepdata))
13921 {
13922 return qe_invalid;
13923 }
13924
13925
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_height),f,keepdata))
13926 {
13927 return qe_invalid;
13928 }
13929
13930
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hp),f,keepdata))
13931 {
13932 return qe_invalid;
13933 }
13934
13935
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.family),f,keepdata))
13936 {
13937 return qe_invalid;
13938 }
13939
13940
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
49152 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13941 {
13942 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13943 {
13944 tempguy.s_tile=tempguy.e_tile+120;
13945 tempguy.s_width=tempguy.e_width;
13946 tempguy.s_height=tempguy.e_height;
13947 }
13948 else tempguy.s_tile=860;
13949 }
13950
13951
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.cset),f,keepdata))
13952 {
13953 return qe_invalid;
13954 }
13955
13956
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.anim),f,keepdata))
13957 {
13958 return qe_invalid;
13959 }
13960
13961
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13962 {
13963 return qe_invalid;
13964 }
13965
13966
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.frate),f,keepdata))
13967 {
13968 return qe_invalid;
13969 }
13970
13971
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13972 {
13973 return qe_invalid;
13974 }
13975
13976
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 13) // April 2009
13977 {
13978 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13979 {
13980 tempguy.frate *= 2;
13981 tempguy.e_frate *= 2;
13982 }
13983 }
13984
13985
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 14) // May 1 2009
13986 {
13987 if(tempguy.anim==a2FRMSLOW)
13988 {
13989 tempguy.anim=a2FRM;
13990 tempguy.frate *= 2;
13991 }
13992
13993 if(tempguy.e_anim==a2FRMSLOW)
13994 {
13995 tempguy.e_anim=a2FRM;
13996 tempguy.e_frate *= 2;
13997 }
13998
13999 if(tempguy.anim==aFLIPSLOW)
14000 {
14001 tempguy.anim=aFLIP;
14002 tempguy.frate *= 2;
14003 }
14004
14005 if(tempguy.e_anim==aFLIPSLOW)
14006 {
14007 tempguy.e_anim=aFLIP;
14008 tempguy.e_frate *= 2;
14009 }
14010
14011 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14012
14013 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14014
14015 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14016 {
14017 tempguy.anim=a4FRM4DIR;
14018 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14019 }
14020
14021 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14022 {
14023 tempguy.e_anim=a4FRM4DIR;
14024 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14025 }
14026 }
14027
14028
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.dp),f,keepdata))
14029 {
14030 return qe_invalid;
14031 }
14032
14033 //correction for guy fire
14034
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 6)
14035 {
14036 if(i == gFIRE)
14037 tempguy.dp = 2;
14038 }
14039
14040
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14041 {
14042 return qe_invalid;
14043 }
14044
14045
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14046 {
14047 return qe_invalid;
14048 }
14049
14050 //correction for bosses using triple, "rising" fireballs
14051
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 5)
14052 {
14053 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14054 i == eGOHMA3 || i == eGOHMA4)
14055 {
14056 if(tempguy.weapon == ewFireball)
14057 tempguy.weapon = ewFireball2;
14058 }
14059 }
14060
14061
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.rate),f,keepdata))
14062 {
14063 return qe_invalid;
14064 }
14065
14066
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14067 {
14068 return qe_invalid;
14069 }
14070
14071
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.step),f,keepdata))
14072 {
14073 return qe_invalid;
14074 }
14075
14076 // HIGHLY UNORTHODOX UPDATING THING, part 2
14077
3/4
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 48640 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
49152 if(fixpolsvoice && tempguy.family==eePOLSV)
14078 {
14079 tempguy.step /= 2;
14080 }
14081
14082
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.homing),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14088 {
14089 return qe_invalid;
14090 }
14091
14092
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14093 {
14094 return qe_invalid;
14095 }
14096
14097
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14098 {
14099
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14130 {
14131 return qe_invalid;
14132 }
14133
14134
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138
14139
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14140 {
14141 return qe_invalid;
14142 }
14143
14144
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148 49152 }
14149 else
14150 {
14151 int16_t tempMisc;
14152
14153 if(!p_igetw(&tempMisc,f,keepdata))
14154 {
14155 return qe_invalid;
14156 }
14157
14158 tempguy.misc1=tempMisc;
14159
14160 if(!p_igetw(&tempMisc,f,keepdata))
14161 {
14162 return qe_invalid;
14163 }
14164
14165 tempguy.misc2=tempMisc;
14166
14167 if(!p_igetw(&tempMisc,f,keepdata))
14168 {
14169 return qe_invalid;
14170 }
14171
14172 tempguy.misc3=tempMisc;
14173
14174 if(!p_igetw(&tempMisc,f,keepdata))
14175 {
14176 return qe_invalid;
14177 }
14178
14179 tempguy.misc4=tempMisc;
14180
14181 if(!p_igetw(&tempMisc,f,keepdata))
14182 {
14183 return qe_invalid;
14184 }
14185
14186 tempguy.misc5=tempMisc;
14187
14188 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14189 {
14190 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14191 tempguy.misc5 = 74;
14192 }
14193
14194 if(!p_igetw(&tempMisc,f,keepdata))
14195 {
14196 return qe_invalid;
14197 }
14198
14199 tempguy.misc6=tempMisc;
14200
14201 if(!p_igetw(&tempMisc,f,keepdata))
14202 {
14203 return qe_invalid;
14204 }
14205
14206 tempguy.misc7=tempMisc;
14207
14208 if(!p_igetw(&tempMisc,f,keepdata))
14209 {
14210 return qe_invalid;
14211 }
14212
14213 tempguy.misc8=tempMisc;
14214
14215 if(!p_igetw(&tempMisc,f,keepdata))
14216 {
14217 return qe_invalid;
14218 }
14219
14220 tempguy.misc9=tempMisc;
14221
14222 if(!p_igetw(&tempMisc,f,keepdata))
14223 {
14224 return qe_invalid;
14225 }
14226
14227 tempguy.misc10=tempMisc;
14228 }
14229
14230
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14236 {
14237 return qe_invalid;
14238 }
14239
14240
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.extend),f,keepdata))
14241 {
14242 return qe_invalid;
14243 }
14244
14245 //! Enemy Defences
14246
14247 //If a 2.50 quest, use only the 2.5 defences.
14248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14249 {
14250
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 49152 times.
983040 for(int32_t j=0; j<edefLAST; j++)
14251 {
14252
1/2
✓ Branch 0 taken 933888 times.
✗ Branch 1 not taken.
933888 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14253 {
14254 return qe_invalid;
14255 }
14256 933888 }
14257 //then copy the generic script defence to all the new script defences
14258
14259 49152 }
14260
14261
14262
14263
14264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 18)
14265 {
14266
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14267 {
14268 return qe_invalid;
14269 }
14270
14271
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14272 {
14273 return qe_invalid;
14274 }
14275 49152 }
14276
14277
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion >= 22)
14278 {
14279
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14280 {
14281 return qe_invalid;
14282 }
14283
14284
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14285 {
14286 return qe_invalid;
14287 }
14288 49152 }
14289 else if(guyversion >= 19)
14290 {
14291 int16_t tempMisc;
14292
14293 if(!p_igetw(&tempMisc,f,keepdata))
14294 {
14295 return qe_invalid;
14296 }
14297
14298 tempguy.misc11=tempMisc;
14299
14300 if(!p_igetw(&tempMisc,f,keepdata))
14301 {
14302 return qe_invalid;
14303 }
14304
14305 tempguy.misc12=tempMisc;
14306 }
14307
14308 //If a 2.54 or later quest, use all of the defences.
14309
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 24) // Add new guyversion conditional statement
14310 {
14311
2/2
✓ Branch 0 taken 247808 times.
✓ Branch 1 taken 11264 times.
259072 for(int32_t j=edefLAST; j<edefLAST255; j++)
14312 {
14313
1/2
✓ Branch 0 taken 247808 times.
✗ Branch 1 not taken.
247808 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14314 {
14315 return qe_invalid;
14316 }
14317 247808 }
14318 11264 }
14319
14320
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14321 {
14322
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14323 {
14324 378880 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14325 378880 }
14326 37888 }
14327
14328 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14329
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 25)
14330 {
14331
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14332 {
14333 return qe_invalid;
14334 }
14335
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14336 {
14337 return qe_invalid;
14338 }
14339
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14340 {
14341 return qe_invalid;
14342 }
14343
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14344 {
14345 return qe_invalid;
14346 }
14347
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14348 {
14349 return qe_invalid;
14350 }
14351 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14352
14353 */
14354 11264 }
14355 //More Enemy Editor vars for 2.60
14356
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 26)
14357 {
14358
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14359 {
14360 return qe_invalid;
14361 }
14362
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14363 {
14364 return qe_invalid;
14365 }
14366
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14367 {
14368 return qe_invalid;
14369 }
14370
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14371 {
14372 return qe_invalid;
14373 }
14374
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14375 {
14376 return qe_invalid;
14377 }
14378 11264 }
14379
14380
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14381 {
14382 37888 tempguy.wpnsprite = 0;
14383 37888 }
14384
14385
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 27)
14386 {
14387
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14388 {
14389 return qe_invalid;
14390 }
14391 11264 }
14392
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14393 {
14394 37888 tempguy.SIZEflags = 0;
14395 37888 }
14396
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 28)
14397 {
14398
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14399 {
14400 return qe_invalid;
14401 }
14402
14403 11264 }
14404
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14405 {
14406 37888 tempguy.frozentile = 0;
14407 37888 tempguy.frozencset = 0;
14408 37888 tempguy.frozenclock = 0;
14409
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14410 37888 }
14411
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 30)
14412 {
14413
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14414 {
14415 return qe_invalid;
14416 }
14417
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14418 {
14419 return qe_invalid;
14420 }
14421
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14422 {
14423 return qe_invalid;
14424 }
14425
2/2
✓ Branch 0 taken 112640 times.
✓ Branch 1 taken 11264 times.
123904 for ( int32_t q = 0; q < 10; q++ ) {
14426
1/2
✓ Branch 0 taken 112640 times.
✗ Branch 1 not taken.
112640 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14427 {
14428 return qe_invalid;
14429 }
14430 112640 }
14431
14432 11264 }
14433
14434
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 34)
14435 {
14436
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14437 {
14438 return qe_invalid;
14439 }
14440
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14441 {
14442 return qe_invalid;
14443 }
14444
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14445 {
14446 return qe_invalid;
14447 }
14448
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14449 {
14450 return qe_invalid;
14451 }
14452
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14453 {
14454 return qe_invalid;
14455 }
14456
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14457 {
14458 return qe_invalid;
14459 }
14460
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14461 {
14462 return qe_invalid;
14463 }
14464
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14465 {
14466 return qe_invalid;
14467 }
14468
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14469 {
14470 return qe_invalid;
14471 }
14472
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14473 {
14474 return qe_invalid;
14475 }
14476
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14477 {
14478 return qe_invalid;
14479 }
14480
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14481 {
14482 return qe_invalid;
14483 }
14484
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14485 {
14486 return qe_invalid;
14487 }
14488
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14489 {
14490 return qe_invalid;
14491 }
14492
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14493 {
14494 return qe_invalid;
14495 }
14496
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14497 {
14498 return qe_invalid;
14499 }
14500
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14505 {
14506 return qe_invalid;
14507 }
14508
14509
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14510
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14511 {
14512 return qe_invalid;
14513 }
14514 360448 }
14515
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14516
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14517 {
14518 return qe_invalid;
14519 }
14520 360448 }
14521
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.script),f,keepdata))
14522 {
14523 return qe_invalid;
14524 }
14525 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14526
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14527 {
14528
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532 90112 }
14533
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 11264 times.
33792 for ( int32_t q = 0; q < 2; q++ )
14534 {
14535
1/2
✓ Branch 0 taken 22528 times.
✗ Branch 1 not taken.
22528 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539 22528 }
14540
14541 11264 }
14542
14543
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 37)
14544 {
14545
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14546 {
14547 return qe_invalid;
14548 }
14549 11264 }
14550
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14551
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 38)
14552 {
14553
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14554 {
14555 return qe_invalid;
14556 }
14557
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14558 {
14559 return qe_invalid;
14560 }
14561
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14562 {
14563 return qe_invalid;
14564 }
14565
14566 11264 }
14567
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 38 )
14568 {
14569 37888 tempguy.misc13 = 0;
14570 37888 tempguy.misc14 = 0;
14571 37888 tempguy.misc15 = 0;
14572 37888 }
14573
14574
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 39 )
14575 {
14576
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14577 {
14578
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14579 {
14580
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14581 {
14582 return qe_invalid;
14583 }
14584 5857280 }
14585
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14586 {
14587
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14588 {
14589 return qe_invalid;
14590 }
14591 5857280 }
14592 90112 }
14593
14594
14595 11264 }
14596
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 39 ) //apply old InitD strings to both
14597 {
14598
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ )
14599 {
14600 303104 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14601 303104 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14602 303104 }
14603 37888 }
14604
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 40 )
14605 {
14606
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14607 {
14608 return qe_invalid;
14609 }
14610 11264 }
14611
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 40 )
14612 {
14613 37888 tempguy.weaponscript = 0;
14614 37888 }
14615 //eweapon script InitD
14616
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 41 )
14617 {
14618
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14619 {
14620
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14621 {
14622 return qe_invalid;
14623 }
14624 90112 }
14625
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if ( guy_cversion < 4 )
14626 {
14627 if ( tempguy.family == eeKEESE )
14628 {
14629
14630 if ( !tempguy.misc1 )
14631 {
14632 tempguy.misc16 = 120;
14633 tempguy.misc17 = 16;
14634
14635 }
14636 }
14637 if ( tempguy.family == eePEAHAT )
14638 {
14639 tempguy.misc16 = 80;
14640 tempguy.misc17 = 16;
14641 }
14642
14643 if ( tempguy.family == eeGHINI )
14644 {
14645 tempguy.misc16 = 120;
14646 tempguy.misc17 = 10;
14647 }
14648
14649 }
14650 11264 }
14651
14652
14653
14654 //default weapon sprites (quest version < 2.54)
14655 //port over old defaults -Z
14656
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 32)
14657 {
14658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.wpnsprite <= 0 )
14659 {
14660
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14661 {
14662 case wNone:
14663 31522 tempguy.wpnsprite = 0; break;
14664
14665 case wSword:
14666 case wBeam:
14667 case wBrang:
14668 case wBomb:
14669 case wSBomb:
14670 case wLitBomb:
14671 case wLitSBomb:
14672 case wArrow:
14673 case wFire:
14674 case wWhistle:
14675 case wBait:
14676 case wWand:
14677 case wMagic:
14678 case wCatching:
14679 case wWind:
14680 case wRefMagic:
14681 case wRefFireball:
14682 case wRefRock:
14683 case wHammer:
14684 case wHookshot:
14685 case wHSHandle:
14686 case wHSChain:
14687 case wSSparkle:
14688 case wFSparkle:
14689 case wSmack:
14690 case wPhantom:
14691 case wCByrna:
14692 case wRefBeam:
14693 case wStomp:
14694 case lwMax:
14695 case wScript1:
14696 case wScript2:
14697 case wScript3:
14698 case wScript4:
14699 case wScript5:
14700 case wScript6:
14701 case wScript7:
14702 case wScript8:
14703 case wScript9:
14704 case wScript10:
14705 case wIce:
14706 //Cannot use any of these weapons yet.
14707 tempguy.wpnsprite = -1;
14708 break;
14709
14710 case wEnemyWeapons:
14711 1257 case ewFireball: tempguy.wpnsprite = 17; break;
14712
14713 289 case ewArrow: tempguy.wpnsprite = 19; break;
14714 306 case ewBrang: tempguy.wpnsprite = 4; break;
14715 908 case ewSword: tempguy.wpnsprite = 20; break;
14716 472 case ewRock: tempguy.wpnsprite = 18; break;
14717 873 case ewMagic: tempguy.wpnsprite = 21; break;
14718 77 case ewBomb: tempguy.wpnsprite = 78; break;
14719 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14720 130 case ewLitBomb: tempguy.wpnsprite = 76; break;
14721 18 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14722 355 case ewFireTrail: tempguy.wpnsprite = 80; break;
14723 734 case ewFlame: tempguy.wpnsprite = 35; break;
14724 104 case ewWind: tempguy.wpnsprite = 36; break;
14725 74 case ewFlame2: tempguy.wpnsprite = 81; break;
14726 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14727 case ewIce: tempguy.wpnsprite = 83; break;
14728 751 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14729
14730
14731 default: break; //No assign.
14732 }
14733 37888 }
14734 37888 }
14735
14736 //default weapon fire sound (quest version < 2.54)
14737 //port over old defaults and zero new data. -Z
14738
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 34)
14739 {
14740
2/2
✓ Branch 0 taken 1212416 times.
✓ Branch 1 taken 37888 times.
1250304 for ( int32_t q = 0; q < 32; q++ )
14741 {
14742 1212416 tempguy.movement[q] = 0;
14743 1212416 tempguy.new_weapon[q] = 0;
14744
14745 1212416 }
14746
14747 //NPC Script attributes.
14748 37888 tempguy.script = 0; //No scripted enemies existed. -Z
14749
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14750
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 37888 times.
113664 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14751
14752 37888 tempguy.misc16 = 0;
14753 37888 tempguy.misc17 = 0;
14754 37888 tempguy.misc18 = 0;
14755 37888 tempguy.misc19 = 0;
14756 37888 tempguy.misc20 = 0;
14757 37888 tempguy.misc21 = 0;
14758 37888 tempguy.misc22 = 0;
14759 37888 tempguy.misc23 = 0;
14760 37888 tempguy.misc24 = 0;
14761 37888 tempguy.misc25 = 0;
14762 37888 tempguy.misc26 = 0;
14763 37888 tempguy.misc27 = 0;
14764 37888 tempguy.misc28 = 0;
14765 37888 tempguy.misc29 = 0;
14766 37888 tempguy.misc30 = 0;
14767 37888 tempguy.misc31 = 0;
14768 37888 tempguy.misc32 = 0;
14769
14770 //old default sounds
14771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.firesfx <= 0 )
14772 {
14773
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14774 {
14775 case wNone:
14776 31522 tempguy.firesfx = 0; break;
14777
14778 case wSword:
14779 case wBeam:
14780 case wBrang:
14781 case wBomb:
14782 case wSBomb:
14783 case wLitBomb:
14784 case wLitSBomb:
14785 case wArrow:
14786 case wFire:
14787 case wWhistle:
14788 case wBait:
14789 case wWand:
14790 case wMagic:
14791 case wCatching:
14792 case wWind:
14793 case wRefMagic:
14794 case wRefFireball:
14795 case wRefRock:
14796 case wHammer:
14797 case wHookshot:
14798 case wHSHandle:
14799 case wHSChain:
14800 case wSSparkle:
14801 case wFSparkle:
14802 case wSmack:
14803 case wPhantom:
14804 case wCByrna:
14805 case wRefBeam:
14806 case wStomp:
14807 case lwMax:
14808 case wScript1:
14809 case wScript2:
14810 case wScript3:
14811 case wScript4:
14812 case wScript5:
14813 case wScript6:
14814 case wScript7:
14815 case wScript8:
14816 case wScript9:
14817 case wScript10:
14818 case wIce:
14819 //Cannot use any of these weapons yet.
14820 tempguy.firesfx = -1;
14821 break;
14822
14823 case wEnemyWeapons:
14824 1257 case ewFireball: tempguy.firesfx = 40; break;
14825
14826 289 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14827 306 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14828 908 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14829 472 case ewRock: tempguy.firesfx = 51; break;
14830 873 case ewMagic: tempguy.firesfx = 32; break;
14831 77 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14832 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14833 130 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14834 18 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14835 355 case ewFireTrail: tempguy.firesfx = 13; break;
14836 734 case ewFlame: tempguy.firesfx = 13; break;
14837 104 case ewWind: tempguy.firesfx = 32; break;
14838 74 case ewFlame2: tempguy.firesfx = 13; break;
14839 case ewFlame2Trail: tempguy.firesfx = 13; break;
14840 case ewIce: tempguy.firesfx = 44; break;
14841 751 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14842
14843 //what about special attacks (e.g. summoning == 56)
14844 default: break; //No assign.
14845 }
14846 37888 }
14847 37888 }
14848
14849 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14850
4/6
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
✓ Branch 2 taken 11264 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11264 times.
49152 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14851 {
14852
2/2
✓ Branch 0 taken 2994 times.
✓ Branch 1 taken 34894 times.
37888 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14853 37888 }
14854 //Keese and bat halt rates.
14855
3/4
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37888 times.
49152 if ( guyversion < 42 && guy_cversion < 4 )
14856 {
14857
14858
2/2
✓ Branch 0 taken 37378 times.
✓ Branch 1 taken 510 times.
37888 if ( tempguy.family == eeKEESE )
14859 {
14860
14861
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 314 times.
510 if ( !tempguy.misc1 )
14862 {
14863 314 tempguy.misc16 = 120;
14864 314 tempguy.misc17 = 16;
14865
14866 314 }
14867 510 }
14868
2/2
✓ Branch 0 taken 37726 times.
✓ Branch 1 taken 162 times.
37888 if ( tempguy.family == eePEAHAT )
14869 {
14870 162 tempguy.misc16 = 80;
14871 162 tempguy.misc17 = 16;
14872 162 }
14873
2/2
✓ Branch 0 taken 37814 times.
✓ Branch 1 taken 74 times.
37888 if ( tempguy.family == eeGHINI )
14874 {
14875 74 tempguy.misc16 = 120;
14876 74 tempguy.misc17 = 10;
14877 74 }
14878
14879
14880 37888 }
14881
14882
14883 //miscellaneous other corrections
14884 //fix the mirror wizzrobe -DD
14885
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 7)
14886 {
14887 if(i == eMWIZ)
14888 {
14889 tempguy.misc2 = 0;
14890 tempguy.misc4 = 1;
14891 }
14892 }
14893
14894
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 8)
14895 {
14896 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14897 {
14898 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14899 tempguy.misc5 = 4; //neck length in segments
14900 tempguy.misc6 = 8; //neck offset from first body tile
14901 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14902 tempguy.misc8 = 168; //head offset from first body tile
14903 tempguy.misc9 = 228; //flying head offset from first body tile
14904
14905 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14906 {
14907 tempguy.misc6 += 10; //neck offset from first body tile
14908 tempguy.misc8 -= 12; //head offset from first body tile
14909 }
14910 }
14911 }
14912
14913
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14914 {
14915 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14916 tempguy.bosspal = spDIG;
14917 }
14918
14919
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 11) // December 2007 - Spinning Tile fix
14920 {
14921 if(tempguy.family==eeSPINTILE)
14922 {
14923 tempguy.flags |= guy_superman;
14924 tempguy.item_set = 0; // Don't drop items
14925 tempguy.step = 300;
14926 }
14927 }
14928
14929
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14930 {
14931 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14932 {
14933 if(tempguy.family==eeROPE)
14934 {
14935 tempguy.flags2 &= ~guy_flashing;
14936 }
14937 }
14938
14939 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14940 {
14941 if(tempguy.family==eeBUBBLE)
14942 {
14943 tempguy.flags2 &= ~guy_flashing;
14944 }
14945 }
14946
14947 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14948 {
14949 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14950 {
14951 tempguy.flags2 |= guy_blinking;
14952 }
14953
14954 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14955 {
14956 tempguy.flags2 |= guy_transparent;
14957 }
14958 }
14959 }
14960
14961
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14962 {
14963 if(i==gFIRE)
14964 {
14965 tempguy.e_anim = aFLIP;
14966 tempguy.e_frate = 24;
14967 }
14968
14969 if(i==gFAIRY)
14970 {
14971 tempguy.e_anim = a2FRM;
14972 tempguy.e_frate = 16;
14973 }
14974 }
14975
14976
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14977 {
14978 if(i==0) Z_message("Updating guys to version 16...\n");
14979
14980 update_guy_1(&tempguy);
14981
14982 if(i==eMPOLSV)
14983 {
14984 tempguy.defense[edefARROW] = edCHINK;
14985 tempguy.defense[edefMAGIC] = ed1HKO;
14986 tempguy.defense[edefREFMAGIC] = ed1HKO;
14987 }
14988 }
14989
14990
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 17) // December 2009
14991 {
14992 if(tempguy.family==eePROJECTILE)
14993 {
14994 tempguy.misc1 = 0;
14995 }
14996 }
14997
14998
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 18) // January 2010
14999 {
15000 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15001 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15002
15003 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15004 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15005
15006 if(tempguy.family == eeAQUA)
15007 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15008 else if(tempguy.family == eeMANHAN)
15009 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15010 else if(tempguy.family==eePATRA)
15011 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15012 else if(tempguy.family==eeGHOMA)
15013 {
15014 for(int32_t j=0; j<edefLAST; j++)
15015 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15016
15017 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15018
15019 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15020
15021 tempguy.misc1--;
15022 }
15023 else if(tempguy.family == eeGLEEOK)
15024 {
15025 for(int32_t j=0; j<edefLAST; j++)
15026 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15027
15028 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15029 }
15030 else if(tempguy.family == eeARMOS)
15031 {
15032 tempguy.family=eeWALK;
15033 tempguy.hrate = 0;
15034 tempguy.misc10 = tempguy.misc1;
15035 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15036 tempguy.misc9 = e9tARMOS;
15037 }
15038 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15039 {
15040 tempguy.family=eeWALK;
15041 tempguy.hrate = 0;
15042 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15043 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15044 }
15045
15046 // Spawn animation flags
15047 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15048 tempguy.flags |= guy_fadeflicker;
15049 else
15050 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15051 }
15052
15053
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 20) // April 2010
15054 {
15055 if(tempguy.family == eeTRAP)
15056 {
15057 tempguy.misc2 = tempguy.misc10;
15058
15059 if(tempguy.misc10>=1)
15060 {
15061 tempguy.misc1++;
15062 }
15063
15064 tempguy.misc10 = 0;
15065 }
15066
15067 // Bomb Blast fix
15068 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15069 tempguy.weapon = ewLitBomb;
15070 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15071 tempguy.weapon = ewLitSBomb;
15072 }
15073
15074
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 21) // September 2011
15075 {
15076 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15077 {
15078 if(tempguy.family == eeKEESETRIB)
15079 {
15080 tempguy.family = eeKEESE;
15081 tempguy.misc2 = e2tKEESETRIB;
15082 tempguy.misc1 = 0;
15083 }
15084
15085 tempguy.rate = 2;
15086 tempguy.hrate = 8;
15087 tempguy.homing = 0;
15088 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15089 }
15090 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15091 {
15092 if(tempguy.family == eePEAHAT)
15093 {
15094 tempguy.rate = 4;
15095 tempguy.step = 62;
15096 }
15097 else
15098 tempguy.step = 25;
15099
15100 tempguy.hrate = 8;
15101 tempguy.homing = 0;
15102 }
15103 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15104 {
15105 if(tempguy.family == eeMANHAN)
15106 tempguy.step=50;
15107
15108 tempguy.hrate = 16;
15109 tempguy.homing = 0;
15110 }
15111 else if(tempguy.family == eeGLEEOK)
15112 {
15113 tempguy.rate = 2;
15114 tempguy.homing = 0;
15115 tempguy.hrate = 9;
15116 tempguy.step=89;
15117 }
15118 else if(tempguy.family == eeGHINI)
15119 {
15120 tempguy.rate = 4;
15121 tempguy.hrate = 12;
15122 tempguy.step=62;
15123 tempguy.homing = 0;
15124 }
15125
15126 // Bigdig random rate fix
15127 if(tempguy.family==eeDIG && tempguy.misc10==1)
15128 {
15129 tempguy.rate = 2;
15130 }
15131 }
15132
15133
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 24) // November 2012
15134 {
15135 if(tempguy.family==eeLANM)
15136 tempguy.misc3 = 1;
15137 else if(tempguy.family==eeMOLD)
15138 tempguy.misc2 = 0;
15139 }
15140
15141
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15142 {
15143
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 37241 times.
37888 if(tempguy.family!=eeDIG)
15144 {
15145 37241 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15146 37241 }
15147
15148 37888 }
15149 // does not seem to solve the issue!
15150
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if ( Header->zelda_version <= 0x210 )
15151 {
15152 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15153 if ( tempguy.family == eeDONGO )
15154 {
15155 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15156 }
15157 }
15158
15159
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion >= 42)
15160 {
15161
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 1024 times.
11264 if(guyversion >= 47)
15162 {
15163
1/2
✓ Branch 0 taken 10240 times.
✗ Branch 1 not taken.
10240 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15164 {
15165 return qe_invalid;
15166 }
15167 10240 }
15168 else
15169 {
15170 byte fl;
15171
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15172 {
15173 return qe_invalid;
15174 }
15175 1024 tempguy.moveflags = fl;
15176 }
15177 11264 }
15178 else
15179 {
15180
7/8
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 29895 times.
✓ Branch 2 taken 1177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 234 times.
✓ Branch 7 taken 5662 times.
37888 switch(tempguy.family)
15181 {
15182 //No gravity; floats over pits
15183 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15184 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15185 //Special (bosses, etc)
15186 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15187 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15188 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15189 29895 tempguy.moveflags = FLAG_CAN_PITWALK;
15190 29895 break;
15191 //No gravity, but falls in pits
15192 case eeLEV:
15193 507 tempguy.moveflags = FLAG_CAN_PITFALL;
15194 507 break;
15195 //Bosses that respect pits
15196 case eeDONGO:
15197 271 tempguy.moveflags = FLAG_OBEYS_GRAV;
15198 271 break;
15199 case eeLANM:
15200 234 tempguy.moveflags = 0;
15201 234 break;
15202 //Gravity, floats over pits
15203 case eeWIZZ: case eeWALLM: case eeGHINI:
15204 1177 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15205 1177 break;
15206 //Gravity and falls in pits
15207 case eeWALK:
15208
4/4
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 5074 times.
5662 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15209 588 break;
15210 [[fallthrough]];
15211 case eeOTHER:
15212 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15213 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15214 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15215 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15216 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15217 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15218 5216 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15219 5216 }
15220 }
15221
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 43)
15222 {
15223
2/2
✓ Branch 0 taken 31072 times.
✓ Branch 1 taken 6816 times.
37888 switch(tempguy.family)
15224 {
15225 //No gravity; floats over pits
15226 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15227 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15228 //Special (bosses, etc)
15229 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15230 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15231 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15232 case eeWIZZ: case eeWALLM: case eeGHINI:
15233 //Gravity, floats over pits
15234 31072 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15235 31072 break;
15236 }
15237 37888 }
15238
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion < 44)
15239 {
15240
2/2
✓ Branch 0 taken 37527 times.
✓ Branch 1 taken 361 times.
37888 if ( tempguy.family == eeGHOMA )
15241 {
15242 361 tempguy.flags |= guy_fadeinstant;
15243 361 }
15244 37888 }
15245
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion > 44)
15246 {
15247
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15248 {
15249 return qe_invalid;
15250 }
15251
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15252 {
15253 return qe_invalid;
15254 }
15255
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15256 {
15257 return qe_invalid;
15258 }
15259 11264 }
15260 else
15261 {
15262
2/2
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 148 times.
37888 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15263 37888 tempguy.spr_death = iwDeath;
15264 37888 tempguy.spr_spawn = iwSpawn;
15265 }
15266
15267
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 46)
15268 {
15269
4/4
✓ Branch 0 taken 5662 times.
✓ Branch 1 taken 32226 times.
✓ Branch 2 taken 5349 times.
✓ Branch 3 taken 313 times.
37888 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15270 {
15271 313 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15272 313 }
15273 37888 }
15274
15275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
15276 {
15277 49152 guysbuf[i] = tempguy;
15278 49152 }
15279 49152 }
15280 96 }
15281
15282 96 return 0;
15283 99 }
15284
15285 void update_guy_1(guydata *tempguy) // November 2009
15286 {
15287 bool doesntcount = false;
15288 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15289
15290 switch(tempguy->family)
15291 {
15292 case 1: //eeWALK
15293 switch(tempguy->misc10)
15294 {
15295 case 0: //Stalfos
15296 if(tempguy->misc1==1) // Fires four projectiles at once
15297 tempguy->misc1=4;
15298
15299 break;
15300
15301 case 1: //Darknut
15302 goto darknuts;
15303 break;
15304 }
15305
15306 tempguy->misc10 = 0;
15307 break;
15308
15309 case 2: //eeSHOOT
15310 tempguy->family = eeWALK;
15311
15312 switch(tempguy->misc10)
15313 {
15314 case 0: //Octorok
15315 if(tempguy->misc1==1||tempguy->misc1==2)
15316 {
15317 tempguy->misc1=e1tFIREOCTO;
15318 tempguy->misc2=e2tFIREOCTO;
15319 }
15320 else tempguy->misc1 = 0;
15321
15322 tempguy->misc6=tempguy->misc4;
15323 tempguy->misc4=tempguy->misc3;
15324 tempguy->misc3=0;
15325 break;
15326
15327 case 1: // Moblin
15328 tempguy->misc1 = 0;
15329 break;
15330
15331 case 2: //Lynel
15332 tempguy->misc6=tempguy->misc1+1;
15333 tempguy->misc1=0;
15334 break;
15335
15336 case 3: //Stalfos 2
15337 if(tempguy->misc1==1) // Fires four projectiles at once
15338 tempguy->misc1=e1t4SHOTS;
15339 else tempguy->misc1 = 0;
15340
15341 break;
15342
15343 case 4: //Darknut 5
15344 darknuts:
15345 tempguy->defense[edefFIRE] = edIGNORE;
15346 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15347 tempguy->defense[edefHOOKSHOT] = 0;
15348 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15349 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15350
15351 if(tempguy->misc1==1)
15352 tempguy->misc1=2;
15353 else if(tempguy->misc1==2)
15354 {
15355 tempguy->misc4=tempguy->misc3;
15356 tempguy->misc3=tempguy->misc2;
15357 tempguy->misc2=e2tSPLIT;
15358 tempguy->misc1 = 0;
15359 }
15360 else tempguy->misc1 = 0;
15361
15362 tempguy->flags |= inv_front;
15363
15364 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15365 tempguy->flags |= guy_bkshield;
15366
15367 break;
15368 }
15369
15370 tempguy->misc10 = 0;
15371 break;
15372
15373 /*
15374 case 9: //eeARMOS
15375 tempguy->family = eeWALK;
15376 break;
15377 */
15378 case 11: //eeGEL
15379 case 33: //eeGELTRIB
15380 if(tempguy->family==33)
15381 {
15382 tempguy->misc4 = 1;
15383
15384 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15385 tempguy->misc3 = tempguy->misc2;
15386
15387 tempguy->misc2 = e2tTRIBBLE;
15388 }
15389 else
15390 {
15391 tempguy->misc4 = 0;
15392 tempguy->misc3 = 0;
15393 tempguy->misc2 = 0;
15394 }
15395
15396 tempguy->family = eeWALK;
15397
15398 if(tempguy->misc1)
15399 {
15400 tempguy->misc1=1;
15401 tempguy->weapon = ewFireTrail;
15402 }
15403
15404 break;
15405
15406 case 34: //eeZOLTRIB
15407 case 12: //eeZOL
15408 tempguy->misc4=tempguy->misc3;
15409 tempguy->misc3=tempguy->misc2;
15410 tempguy->family = eeWALK;
15411 tempguy->misc2=e2tSPLITHIT;
15412
15413 if(tempguy->misc1)
15414 {
15415 tempguy->misc1=1;
15416 tempguy->weapon = ewFireTrail;
15417 }
15418
15419 break;
15420
15421 case 13: //eeROPE
15422 tempguy->family = eeWALK;
15423 tempguy->misc9 = e9tROPE;
15424
15425 if(tempguy->misc1)
15426 {
15427 tempguy->misc4 = tempguy->misc3;
15428 tempguy->misc3 = tempguy->misc2;
15429 tempguy->misc2 = e2tBOMBCHU;
15430 }
15431
15432 tempguy->misc1 = 0;
15433 break;
15434
15435 case 14: //eeGORIYA
15436 tempguy->family = eeWALK;
15437
15438 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15439
15440 break;
15441
15442 case 17: //eeBUBBLE
15443 tempguy->family = eeWALK;
15444 tempguy->misc8 = tempguy->misc2;
15445 tempguy->misc7 = tempguy->misc1 + 1;
15446 tempguy->misc1 = tempguy->misc2 = 0;
15447
15448 //fallthrogh
15449 case eeTRAP:
15450 case eeROCK:
15451 doesntcount = true;
15452 break;
15453
15454 case 35: //eeVIRETRIB
15455 case 18: //eeVIRE
15456 tempguy->family = eeWALK;
15457 tempguy->misc4=tempguy->misc3;
15458 tempguy->misc3=tempguy->misc2;
15459 tempguy->misc2=e2tSPLITHIT;
15460 tempguy->misc9=e9tVIRE;
15461 break;
15462
15463 case 19: //eeLIKE
15464 tempguy->family = eeWALK;
15465 tempguy->misc7 = e7tEATITEMS;
15466 tempguy->misc8=95;
15467 break;
15468
15469 case 20: //eePOLSV
15470 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15471 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15472 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15473 tempguy->defense[edefARROW] = ed1HKO;
15474 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15475 tempguy->family = eeWALK;
15476 tempguy->misc9 = e9tPOLSVOICE;
15477 tempguy->rate = 4;
15478 tempguy->homing = 32;
15479 tempguy->hrate = 10;
15480 tempguy->grumble = 0;
15481 break;
15482
15483 case eeWIZZ:
15484 if(tempguy->misc4)
15485 {
15486 for(int32_t i=0; i < edefLAST; i++)
15487 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15488 }
15489 else
15490 {
15491 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15492 tempguy->defense[edefMAGIC] = edCHINK;
15493 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15494 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15495 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15496 }
15497
15498 break;
15499
15500 case eePEAHAT:
15501 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15502
15503 if(!(tempguy->flags & guy_bhit))
15504 tempguy->defense[edefBRANG] = edSTUNONLY;
15505
15506 break;
15507
15508 case eeLEV:
15509 tempguy->defense[edefSTOMP] = edCHINK;
15510 break;
15511 }
15512
15513 // Old flags
15514 if(tempguy->flags & guy_superman)
15515 {
15516 for(int32_t i = 0; i < edefLAST; i++)
15517 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15518 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15519 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15520 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15521 }
15522
15523 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15524
15525 if(doesntcount)
15526 tempguy->flags |= (guy_doesntcount);
15527 }
15528
15529
15530 144976 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15531 {
15532 byte tempbyte, padding;
15533 int32_t extras, secretcombos;
15534 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->valid),f,true))
15536 {
15537 return qe_invalid;
15538 }
15539
15540
15541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->guy),f,true))
15542 {
15543 return qe_invalid;
15544 }
15545
15546
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15547 {
15548 if(!p_getc(&tempbyte,f,true))
15549 {
15550 return qe_invalid;
15551 }
15552
15553 temp_mapscr->str=tempbyte;
15554 }
15555 else
15556 {
15557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->str),f,true))
15558 {
15559 return qe_invalid;
15560 }
15561 }
15562
15563
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->room),f,true))
15564 {
15565 return qe_invalid;
15566 }
15567
15568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->item),f,true))
15569 {
15570 return qe_invalid;
15571 }
15572
15573
3/6
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133960 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15574 {
15575 11016 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15576 11016 }
15577 else
15578 {
15579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15580 return qe_invalid;
15581 }
15582
15583
1/4
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version < 0x192)||
15584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15585 {
15586 if(!p_getc(&tempbyte,f,true))
15587 {
15588 return qe_invalid;
15589 }
15590 }
15591
15592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15593 {
15594 return qe_invalid;
15595 }
15596
15597
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15598 {
15599 if(!p_getc(&tempbyte,f,true))
15600 {
15601 return qe_invalid;
15602 }
15603 }
15604
15605
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15606 {
15607
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15608 {
15609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15610 {
15611 return qe_invalid;
15612 }
15613 401880 }
15614 133960 }
15615 else
15616 {
15617 11016 temp_mapscr->tilewarptype[1]=0;
15618 11016 temp_mapscr->tilewarptype[2]=0;
15619 11016 temp_mapscr->tilewarptype[3]=0;
15620 }
15621
15622
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15623 {
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15625 {
15626 return qe_invalid;
15627 }
15628 144976 }
15629
15630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15631 {
15632 return qe_invalid;
15633 }
15634
15635 144976 temp_mapscr->warpreturnx[1]=0;
15636 144976 temp_mapscr->warpreturnx[2]=0;
15637 144976 temp_mapscr->warpreturnx[3]=0;
15638
15639
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15640 {
15641
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15642 {
15643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15644 {
15645 return qe_invalid;
15646 }
15647 401880 }
15648 133960 }
15649
15650
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15651 {
15652 return qe_invalid;
15653 }
15654
15655 144976 temp_mapscr->warpreturny[1]=0;
15656 144976 temp_mapscr->warpreturny[2]=0;
15657 144976 temp_mapscr->warpreturny[3]=0;
15658
15659
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15660 {
15661
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15662 {
15663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15664 {
15665 return qe_invalid;
15666 }
15667 401880 }
15668
15669
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(version>=18)
15670 {
15671
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15672 {
15673 return qe_invalid;
15674 }
15675 133960 }
15676 else
15677 {
15678 byte temp;
15679
15680 if(!p_getc(&temp,f,true))
15681 {
15682 return qe_invalid;
15683 }
15684
15685 temp_mapscr->warpreturnc=temp<<8|temp;
15686 }
15687 133960 }
15688
15689
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->stairx),f,true))
15690
15691 {
15692 return qe_invalid;
15693 }
15694
15695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->stairy),f,true))
15696 {
15697 return qe_invalid;
15698 }
15699
15700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemx),f,true))
15701 {
15702 return qe_invalid;
15703 }
15704
15705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemy),f,true))
15706 {
15707 return qe_invalid;
15708 }
15709
15710
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version > 15) // February 2009
15711 {
15712
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->color),f,true))
15713 {
15714 return qe_invalid;
15715 }
15716 133960 }
15717 else
15718 {
15719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(!p_getc(& tempbyte,f,true))
15720 {
15721 return qe_invalid;
15722 }
15723
15724 11016 temp_mapscr->color = (word) tempbyte;
15725 }
15726
15727
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15728 {
15729 return qe_invalid;
15730 }
15731
15732
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15733 {
15734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15735 {
15736 return qe_invalid;
15737
15738 }
15739 579904 }
15740
15741
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
15742 {
15743
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
15744 {
15745 return qe_invalid;
15746 }
15747
15748 11016 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15749
15750
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15751 {
15752 for(int32_t i=1; i<4; i++)
15753 {
15754 if(!p_getc(&(tempbyte),f,true))
15755 {
15756 return qe_invalid;
15757 }
15758
15759 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15760 }
15761 }
15762 else
15763 {
15764 11016 temp_mapscr->tilewarpdmap[1]=0;
15765 11016 temp_mapscr->tilewarpdmap[2]=0;
15766 11016 temp_mapscr->tilewarpdmap[3]=0;
15767 }
15768 11016 }
15769 else
15770 {
15771
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
15772 {
15773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15774 {
15775 return qe_invalid;
15776 }
15777 535840 }
15778 }
15779
15780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15781 {
15782 return qe_invalid;
15783 }
15784
15785
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15786 {
15787
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15788 {
15789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15790 {
15791 return qe_invalid;
15792 }
15793 401880 }
15794 133960 }
15795 else
15796 {
15797 11016 temp_mapscr->tilewarpscr[1]=0;
15798 11016 temp_mapscr->tilewarpscr[2]=0;
15799 11016 temp_mapscr->tilewarpscr[3]=0;
15800 }
15801
15802
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15803 {
15804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15805 {
15806 return qe_invalid;
15807 }
15808 133960 }
15809 else
15810 {
15811 11016 temp_mapscr->tilewarpoverlayflags=0;
15812 }
15813
15814
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15815 {
15816 return qe_invalid;
15817 }
15818
15819
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15820 {
15821 if(!p_getc(&tempbyte,f,true))
15822 {
15823 return qe_invalid;
15824 }
15825
15826 }
15827
15828
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15829 {
15830 if(!p_getc(&padding,f,true))
15831 {
15832 return qe_invalid;
15833 }
15834 }
15835
15836
2/2
✓ Branch 0 taken 1449760 times.
✓ Branch 1 taken 144976 times.
1594736 for(int32_t k=0; k<10; k++)
15837 {
15838 /*
15839 if (!temp_mapscr->enemy[k])
15840 {
15841 continue;
15842 }
15843 */
15844
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15845 {
15846 if(!p_getc(&tempbyte,f,true))
15847 {
15848 return qe_invalid;
15849 }
15850
15851 temp_mapscr->enemy[k]=tempbyte;
15852 }
15853 else
15854 {
15855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1449760 times.
1449760 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15856 {
15857 return qe_invalid;
15858 }
15859 }
15860
15861
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15862 {
15863 //using enumerations here is dangerous
15864 //very easy to break old quests -DD
15865 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15866 {
15867 temp_mapscr->enemy[k]+=5;
15868 }
15869 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15870 {
15871 temp_mapscr->enemy[k]+=1;
15872 }
15873 }
15874
15875
2/2
✓ Branch 0 taken 1339600 times.
✓ Branch 1 taken 110160 times.
1449760 if(version < 9)
15876 {
15877
2/2
✓ Branch 0 taken 102675 times.
✓ Branch 1 taken 7485 times.
110160 if(temp_mapscr->enemy[k]>0)
15878 {
15879 7485 temp_mapscr->enemy[k]+=10;
15880 7485 }
15881 110160 }
15882 //don't read in any invalid data
15883
1/2
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
1449760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15884 {
15885 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15886 temp_mapscr->enemy[k] = 0;
15887 }
15888 1449760 }
15889
15890
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->pattern),f,true))
15891 {
15892 return qe_invalid;
15893 }
15894
15895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15896 {
15897 return qe_invalid;
15898 }
15899
15900
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15901 {
15902
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15903 {
15904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15905 {
15906 return qe_invalid;
15907 }
15908 401880 }
15909 133960 }
15910 else
15911 {
15912 11016 temp_mapscr->sidewarptype[1]=0;
15913 11016 temp_mapscr->sidewarptype[2]=0;
15914 11016 temp_mapscr->sidewarptype[3]=0;
15915 }
15916
15917
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15918 {
15919
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15920 {
15921 return qe_invalid;
15922 }
15923 133960 }
15924 else
15925 {
15926 11016 temp_mapscr->sidewarpoverlayflags=0;
15927 }
15928
15929
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15930 {
15931 return qe_invalid;
15932 }
15933
15934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15935 {
15936 return qe_invalid;
15937 }
15938
15939
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15940 {
15941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15942 {
15943 return qe_invalid;
15944 }
15945 579904 }
15946
15947
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15948 {
15949 return qe_invalid;
15950 }
15951
15952
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15953 {
15954
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 401880 times.
535840 for(int32_t i=1; i<4; i++)
15955 {
15956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15957 {
15958 return qe_invalid;
15959 }
15960 401880 }
15961 133960 }
15962 else
15963 {
15964 11016 temp_mapscr->sidewarpscr[1]=0;
15965 11016 temp_mapscr->sidewarpscr[2]=0;
15966 11016 temp_mapscr->sidewarpscr[3]=0;
15967 }
15968
15969
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
15970 {
15971
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
15972 {
15973 return qe_invalid;
15974 }
15975
15976 11016 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15977
15978
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15979 {
15980 for(int32_t i=1; i<4; i++)
15981 {
15982 if(!p_getc(&(tempbyte),f,true))
15983 {
15984 return qe_invalid;
15985 }
15986
15987 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15988 }
15989 }
15990 else
15991 {
15992 11016 temp_mapscr->sidewarpdmap[1]=0;
15993 11016 temp_mapscr->sidewarpdmap[2]=0;
15994 11016 temp_mapscr->sidewarpdmap[3]=0;
15995 }
15996 11016 }
15997 else
15998 {
15999
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
16000 {
16001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16002 {
16003 return qe_invalid;
16004 }
16005 535840 }
16006 }
16007
16008
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16009 {
16010
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16011 {
16012 return qe_invalid;
16013 }
16014 133960 }
16015 11016 else temp_mapscr->sidewarpindex = 0;
16016
16017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16018 {
16019 return qe_invalid;
16020 }
16021
16022
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
16023 {
16024 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16025 {
16026 return qe_invalid;
16027 }
16028 }
16029
16030
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16031 {
16032 return qe_invalid;
16033 }
16034
16035
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16036 {
16037 return qe_invalid;
16038 }
16039
16040
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->flags),f,true))
16041 {
16042 return qe_invalid;
16043 }
16044
16045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags2),f,true))
16046 {
16047 return qe_invalid;
16048 }
16049
16050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags3),f,true))
16051 {
16052 return qe_invalid;
16053 }
16054
16055
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16056 //if (version>2)
16057 {
16058
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags4),f,true))
16059 {
16060 return qe_invalid;
16061 }
16062 133960 }
16063
16064
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16065 {
16066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags5),f,true))
16067 {
16068 return qe_invalid;
16069 }
16070
16071
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16072 {
16073 return qe_invalid;
16074 }
16075
16076
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16077 {
16078 return qe_invalid;
16079 }
16080
16081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(temp_mapscr->flags5&32)
16082 {
16083 temp_mapscr->flags5 &= ~32;
16084 temp_mapscr->noreset |= 48;
16085 }
16086
16087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(version<8)
16088 {
16089 if(temp_mapscr->noreset&1)
16090 {
16091 temp_mapscr->noreset|=8192;
16092 }
16093
16094 if(temp_mapscr->nocarry&1)
16095 {
16096 temp_mapscr->nocarry|=8192;
16097 temp_mapscr->nocarry&=~1;
16098 }
16099 }
16100 133960 }
16101 else
16102 {
16103 11016 temp_mapscr->flags5 = 0;
16104 11016 temp_mapscr->noreset = 0;
16105 11016 temp_mapscr->nocarry = 0;
16106 }
16107
16108
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16109 {
16110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags6),f,true))
16111 {
16112 return qe_invalid;
16113 }
16114 133960 }
16115
16116
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>5)
16117 {
16118
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags7),f,true))
16119 {
16120 return qe_invalid;
16121 }
16122
16123
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags8),f,true))
16124 {
16125 return qe_invalid;
16126 }
16127
16128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags9),f,true))
16129 {
16130 return qe_invalid;
16131 }
16132
16133
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags10),f,true))
16134 {
16135 return qe_invalid;
16136 }
16137
16138
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16139 {
16140 return qe_invalid;
16141 }
16142 133960 }
16143 else
16144 {
16145 11016 temp_mapscr->csensitive=1;
16146 }
16147
16148
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<14) // August 2007: screen SFX added
16149 {
16150
2/2
✓ Branch 0 taken 10962 times.
✓ Branch 1 taken 54 times.
11016 if(temp_mapscr->flags&8) //fROAR
16151 {
16152 54 temp_mapscr->bosssfx=
16153
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 45 times.
54 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16154 45 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16155 WAV_ROAR;
16156 54 }
16157
16158
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 10941 times.
11016 if(temp_mapscr->flags&128) //fSEA
16159 {
16160 75 temp_mapscr->oceansfx=WAV_SEA;
16161 75 }
16162
16163 11016 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16164 ? 0 : WAV_SECRET;
16165
16166 11016 temp_mapscr->flags3 &= ~66; //64|2
16167 11016 temp_mapscr->flags2 &= ~32;
16168 11016 temp_mapscr->flags &= ~136; // 128|8
16169 11016 }
16170 else
16171 {
16172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16173 {
16174 return qe_invalid;
16175 }
16176
16177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16178 {
16179 return qe_invalid;
16180 }
16181
16182
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16183 {
16184 return qe_invalid;
16185 }
16186 }
16187
16188
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<15) // October 2007: another SFX
16189 {
16190 11016 temp_mapscr->holdupsfx=WAV_PICKUP;
16191 11016 }
16192 else
16193 {
16194
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16195 {
16196 return qe_invalid;
16197 }
16198 }
16199
16200
16201
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16202 {
16203
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16204 {
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16206 {
16207 return qe_invalid;
16208 }
16209 869856 }
16210
16211
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 869856 times.
1014832 for(int32_t k=0; k<6; k++)
16212 {
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16214 {
16215 return qe_invalid;
16216 }
16217 869856 }
16218 144976 }
16219 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16220 {
16221 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16222 {
16223 return qe_invalid;
16224 }
16225
16226 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16227 {
16228 return qe_invalid;
16229 }
16230
16231 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16232 {
16233 return qe_invalid;
16234 }
16235
16236 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16237
16238 {
16239 return qe_invalid;
16240 }
16241 }
16242
16243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16244 {
16245 for(int32_t k=0; k<6; k++)
16246 {
16247 if(!p_getc(&tempbyte,f,true)) //layerxsize
16248 {
16249 return qe_invalid;
16250 }
16251 }
16252
16253 for(int32_t k=0; k<6; k++)
16254 {
16255 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16256 {
16257 return qe_invalid;
16258 }
16259 }
16260
16261 for(int32_t k=0; k<6; k++)
16262 {
16263 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16264 {
16265 return qe_invalid;
16266 }
16267 }
16268
16269 for(int32_t k=0; k<6; k++)
16270 {
16271 if(!p_getc(&tempbyte,f,true)) //layerysize
16272 {
16273 return qe_invalid;
16274 }
16275 }
16276
16277 for(int32_t k=0; k<6; k++)
16278 {
16279 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16280 {
16281 return qe_invalid;
16282 }
16283 }
16284
16285 for(int32_t k=0; k<6; k++)
16286 {
16287 if(!p_getc(&tempbyte,f,true)) //layerydelay
16288 {
16289 return qe_invalid;
16290 }
16291 }
16292 }
16293
16294
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16295 {
16296
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16297 {
16298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16299 {
16300 return qe_invalid;
16301 }
16302 869856 }
16303 144976 }
16304
16305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16306 {
16307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>153))
16308 {
16309 if(!p_getc(&padding,f,true))
16310 {
16311 return qe_invalid;
16312 }
16313 }
16314
16315
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16316 {
16317 return qe_invalid;
16318 }
16319 144976 }
16320
16321
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16322 {
16323 extras=15;
16324 }
16325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16326 {
16327 extras=11;
16328 }
16329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16330 {
16331 extras=32;
16332 }
16333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16334 {
16335 extras=64;
16336 }
16337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 else if(Header->zelda_version < 0x193)
16338 {
16339 extras=62;
16340 }
16341 else
16342
16343 {
16344 144976 extras=0;
16345 }
16346
16347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 for(int32_t k=0; k<extras; k++)
16348 {
16349 if(!p_getc(&tempbyte,f,true)) //extra[k]
16350 {
16351 return qe_invalid;
16352 }
16353 }
16354
16355
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16356 //if (version>3)
16357 {
16358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16359 {
16360 return qe_invalid;
16361 }
16362
16363
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16364 {
16365 return qe_invalid;
16366 }
16367 133960 }
16368 else
16369 {
16370 11016 temp_mapscr->nextmap=0;
16371 11016 temp_mapscr->nextscr=0;
16372 }
16373
16374
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16375 {
16376 secretcombos=20;
16377 }
16378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16379 {
16380 secretcombos=256;
16381 }
16382 else
16383 {
16384 144976 secretcombos=128;
16385 }
16386
16387
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16388 {
16389 for(int32_t k=0; k<secretcombos; k++)
16390 {
16391 if(!p_getc(&tempbyte,f,true))
16392 {
16393 return qe_invalid;
16394 }
16395
16396 if(k<128)
16397 {
16398 temp_mapscr->secretcombo[k]=tempbyte;
16399 }
16400 }
16401 }
16402 else
16403 {
16404
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16405 {
16406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16407 {
16408 return qe_invalid;
16409 }
16410
16411 18556928 }
16412 }
16413
16414
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16415 {
16416
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16417 {
16418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16419 {
16420 return qe_invalid;
16421 }
16422 18556928 }
16423
16424
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16425 {
16426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16427 {
16428 return qe_invalid;
16429 }
16430 18556928 }
16431 144976 }
16432
16433
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16434 {
16435 if(!p_getc(&padding,f,true))
16436 {
16437 return qe_invalid;
16438 }
16439 }
16440
16441 144976 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16442
16443
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16444 {
16445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16446 {
16447 return qe_invalid;
16448 }
16449 25515776 }
16450
16451
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16452 {
16453 if(!p_getc(&padding,f,true))
16454 {
16455 return qe_invalid;
16456 }
16457
16458 if(!p_getc(&padding,f,true))
16459 {
16460 return qe_invalid;
16461 }
16462 }
16463
16464
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16465 {
16466
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16467 {
16468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16469 {
16470 return qe_invalid;
16471 }
16472
16473
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25515776 if((Header->zelda_version == 0x192)&&(Header->build<24))
16474 {
16475 if(!p_getc(&tempbyte,f,true))
16476 {
16477 return qe_invalid;
16478 }
16479
16480 if(!p_getc(&tempbyte,f,true))
16481 {
16482 return qe_invalid;
16483 }
16484
16485 if(!p_getc(&tempbyte,f,true))
16486 {
16487 return qe_invalid;
16488 }
16489 }
16490 25515776 }
16491 144976 }
16492
16493
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16494 {
16495
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 25515776 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16496 {
16497
16498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16499 {
16500 return qe_invalid;
16501 }
16502 25515776 }
16503 144976 }
16504
16505
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16506 {
16507 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16508 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16509 }
16510
16511
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16512 {
16513 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16514 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16515 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16516 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16517 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16518 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16519 }
16520
16521
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16522 {
16523 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16524 {
16525 if((Header->zelda_version == 0x192)&&(Header->build>149))
16526 {
16527 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16528 {
16529 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16530 }
16531 }
16532 else
16533 {
16534 if((Header->zelda_version < 0x192)||
16535 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16536 {
16537 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16538 }
16539
16540 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16541 }
16542
16543 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16544 }
16545 }
16546
16547 /*if(version>12)
16548 {
16549 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16550 {
16551 return qe_invalid;
16552 }
16553 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16554 {
16555 return qe_invalid;
16556 }
16557 }*/
16558
16559
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>4)
16560 {
16561
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16562 {
16563 return qe_invalid;
16564 }
16565 133960 }
16566 else
16567 {
16568 11016 temp_mapscr->screen_midi = -1;
16569 }
16570
16571
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>=17)
16572 {
16573
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16574 {
16575 return qe_invalid;
16576 }
16577 133960 }
16578 else
16579 {
16580 11016 temp_mapscr->lens_layer = llNORMAL;
16581 }
16582
16583
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version>6)
16584 {
16585 dword bits;
16586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_igetl(&bits,f,true))
16587 {
16588 return qe_invalid;
16589 }
16590
16591 int32_t m;
16592 float tempfloat;
16593 word tempw;
16594 133960 temp_mapscr->ffcCountMarkDirty();
16595
16596
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 4286720 times.
4420680 for(m=0; m<32; m++)
16597 {
16598 4286720 ffcdata& tempffc = temp_mapscr->ffcs[m];
16599 4286720 tempffc.clear();
16600
2/2
✓ Branch 0 taken 4275651 times.
✓ Branch 1 taken 11069 times.
4286720 if((bits>>m)&1)
16601 {
16602
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetw(&tempw,f,true))
16603 {
16604 return qe_invalid;
16605 }
16606 11069 tempffc.setData(tempw);
16607
16608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.cset),f,true))
16609 {
16610 return qe_invalid;
16611 }
16612
16613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.delay),f,true))
16614 {
16615 return qe_invalid;
16616 }
16617
16618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(version < 9)
16619 {
16620 if(!p_igetf(&tempfloat,f,true))
16621 {
16622 return qe_invalid;
16623 }
16624
16625 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16626
16627 if(!p_igetf(&tempfloat,f,true))
16628 {
16629 return qe_invalid;
16630 }
16631
16632 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16633
16634 if(!p_igetf(&tempfloat,f,true))
16635 {
16636 return qe_invalid;
16637 }
16638
16639 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16640
16641 if(!p_igetf(&tempfloat,f,true))
16642 {
16643 return qe_invalid;
16644 }
16645
16646 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16647
16648 if(!p_igetf(&tempfloat,f,true))
16649 {
16650 return qe_invalid;
16651 }
16652
16653 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16654
16655 if(!p_igetf(&tempfloat,f,true))
16656 {
16657 return qe_invalid;
16658 }
16659
16660 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16661 }
16662 else
16663 {
16664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.x),f,true))
16665 {
16666 return qe_invalid;
16667 }
16668
16669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.y),f,true))
16670 {
16671 return qe_invalid;
16672 }
16673
16674
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetzf(&(tempffc.vx),f,true))
16675 {
16676 return qe_invalid;
16677 }
16678
16679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.vy),f,true))
16680 {
16681 return qe_invalid;
16682 }
16683
16684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ax),f,true))
16685 {
16686 return qe_invalid;
16687 }
16688
16689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ay),f,true))
16690 {
16691 return qe_invalid;
16692 }
16693 }
16694
16695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.link),f,true))
16696 {
16697 return qe_invalid;
16698 }
16699
16700
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>7)
16701 {
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16703 {
16704 return qe_invalid;
16705 }
16706
16707 11069 tempffc.hxsz = (tempbyte&0x3F)+1;
16708 11069 tempffc.txsz = (tempbyte>>6)+1;
16709
16710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16711 {
16712 return qe_invalid;
16713 }
16714
16715 11069 tempffc.hysz = (tempbyte&0x3F)+1;
16716 11069 tempffc.tysz = (tempbyte>>6)+1;
16717
16718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.flags),f,true))
16719 {
16720 return qe_invalid;
16721 }
16722 11069 }
16723 else
16724 {
16725 tempffc.hxsz=16;
16726 tempffc.hysz=16;
16727 tempffc.txsz=1;
16728 tempffc.tysz=1;
16729 tempffc.flags=0;
16730 }
16731
16732 11069 tempffc.updateSolid();
16733
16734
16735
4/6
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9049 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9049 times.
11069 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16736 {
16737 tempffc.flags|=ffIGNOREHOLDUP;
16738 }
16739
16740
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>9)
16741 {
16742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.script),f,true))
16743 {
16744 return qe_invalid;
16745 }
16746 11069 }
16747 else
16748 {
16749 tempffc.script=0;
16750 }
16751
16752
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>10)
16753 {
16754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[0]),f,true))
16755 {
16756 return qe_invalid;
16757 }
16758
16759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[1]),f,true))
16760 {
16761 return qe_invalid;
16762 }
16763
16764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[2]),f,true))
16765 {
16766 return qe_invalid;
16767 }
16768
16769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[3]),f,true))
16770 {
16771 return qe_invalid;
16772 }
16773
16774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[4]),f,true))
16775 {
16776 return qe_invalid;
16777 }
16778
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[5]),f,true))
16780 {
16781 return qe_invalid;
16782 }
16783
16784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[6]),f,true))
16785 {
16786 return qe_invalid;
16787 }
16788
16789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[7]),f,true))
16790 {
16791 return qe_invalid;
16792 }
16793
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16795 {
16796 return qe_invalid;
16797 }
16798
16799 11069 tempffc.inita[0]=tempbyte*10000;
16800
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16802 {
16803 return qe_invalid;
16804 }
16805
16806 11069 tempffc.inita[1]=tempbyte*10000;
16807 11069 }
16808 else
16809 {
16810 tempffc.inita[0] = 10000;
16811 tempffc.inita[1] = 10000;
16812 }
16813
16814 11069 tempffc.initialized = false;
16815
16816
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version <= 11)
16817 {
16818 fixffcs=true;
16819 }
16820 11069 }
16821 4286720 }
16822
16823 133960 }
16824
16825 //add in the new whistle flags
16826
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version<13)
16827 {
16828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(temp_mapscr->flags & fWHISTLE)
16829 {
16830 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16831 }
16832 11016 }
16833
16834 // for(int32_t m=0; m<32; m++)
16835 // {
16836 // // ffcScriptData used to be part of mapscr, and this was handled just above
16837 // ffcScriptData[m].a[0] = 10000;
16838 // ffcScriptData[m].a[1] = 10000;
16839 // }
16840
16841 //2.55 starts here
16842
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 19 && Header->zelda_version > 0x253 )
16843 {
16844
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16845 {
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16847 {
16848 return qe_invalid;
16849 }
16850 137360 }
16851
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16852 {
16853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16854 {
16855 return qe_invalid;
16856 }
16857 137360 }
16858
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16859 {
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16861 {
16862 return qe_invalid;
16863 }
16864 137360 }
16865
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16866 {
16867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16868 {
16869 return qe_invalid;
16870 }
16871 137360 }
16872 13736 }
16873
3/4
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131240 times.
144976 if ( version < 19 && Header->zelda_version > 0x253 )
16874 {
16875 for ( int32_t q = 0; q < 10; q++ )
16876 {
16877 temp_mapscr->npcstrings[q] = 0;
16878 temp_mapscr->new_items[q] = 0;
16879 temp_mapscr->new_item_x[q] = 0;
16880 temp_mapscr->new_item_y[q] = 0;
16881 }
16882 }
16883
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 20 && Header->zelda_version > 0x253 )
16884 {
16885
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
16886 {
16887 return qe_invalid;
16888 }
16889
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16890 {
16891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16892 {
16893 return qe_invalid;
16894 }
16895 109888 }
16896 13736 }
16897
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
144976 if ( version < 20 )
16898 {
16899 131240 temp_mapscr->script = 0;
16900
2/2
✓ Branch 0 taken 1049920 times.
✓ Branch 1 taken 131240 times.
1181160 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16901 131240 }
16902
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 21 && Header->zelda_version > 0x253 )
16903 {
16904
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16905 {
16906 return qe_invalid;
16907 }
16908 13736 }
16909
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 21 )
16910 {
16911 131240 temp_mapscr->preloadscript = 0;
16912 131240 }
16913 //all builds with version > 20 need this. -Z
16914 144976 temp_mapscr->ffcswaitdraw = 0;
16915
16916
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16919 {
16920 return qe_invalid;
16921 }
16922
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16923 {
16924 return qe_invalid;
16925 }
16926 13736 }
16927
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 22 )
16928 {
16929 131240 temp_mapscr->hidelayers = 0;
16930 131240 temp_mapscr->hidescriptlayers = 0;
16931 131240 }
16932
16933 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16934 //May be any version before 2.11. -Z
16935 /* --not the roar, the HIT SFX
16936 if ( Header->zelda_version <= 0x210 )
16937 {
16938 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16939 {
16940 temp_mapscr->bosssfx = WAV_ROAR;
16941 }
16942 }
16943 */
16944
16945 144976 return 0;
16946 144976 }
16947 157216 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16948 {
16949
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 12240 times.
157216 if(version < 23)
16950 {
16951 144976 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16952
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(ret) return ret;
16953 144976 }
16954 else
16955 {
16956
1/2
✓ Branch 0 taken 12240 times.
✗ Branch 1 not taken.
12240 if(!p_getc(&(temp_mapscr->valid),f,true))
16957 return qe_invalid;
16958
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 7006 times.
12240 if(!(temp_mapscr->valid & mVALID))
16959 7006 return 0; //Empty screen
16960 uint32_t scr_has_flags;
16961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5234 times.
5234 if(!p_igetl(&scr_has_flags,f,true))
16962 return qe_invalid;
16963
16964
2/2
✓ Branch 0 taken 5189 times.
✓ Branch 1 taken 45 times.
5234 if(scr_has_flags & SCRHAS_ROOMDATA)
16965 {
16966
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
16967 return qe_invalid;
16968
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
16969 return qe_invalid;
16970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
16971 return qe_invalid;
16972
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16973 return qe_invalid;
16974 45 }
16975
2/2
✓ Branch 0 taken 5153 times.
✓ Branch 1 taken 81 times.
5234 if(scr_has_flags & SCRHAS_ITEM)
16976 {
16977
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
16978 return qe_invalid;
16979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16980 return qe_invalid;
16981
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
16982 return qe_invalid;
16983
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
16984 return qe_invalid;
16985 81 }
16986
2/2
✓ Branch 0 taken 4942 times.
✓ Branch 1 taken 292 times.
5234 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16987 {
16988
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16989 return qe_invalid;
16990 292 }
16991
2/2
✓ Branch 0 taken 5036 times.
✓ Branch 1 taken 198 times.
5234 if(scr_has_flags & SCRHAS_TWARP)
16992 {
16993
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
16994 {
16995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
16996 return qe_invalid;
16997 792 }
16998
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
16999 {
17000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17001 return qe_invalid;
17002 792 }
17003
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17004 {
17005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17006 return qe_invalid;
17007 792 }
17008
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17009 return qe_invalid;
17010 198 }
17011
2/2
✓ Branch 0 taken 5116 times.
✓ Branch 1 taken 118 times.
5234 if(scr_has_flags & SCRHAS_SWARP)
17012 {
17013
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17014 {
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17016 return qe_invalid;
17017 472 }
17018
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17019 {
17020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17021 return qe_invalid;
17022 472 }
17023
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17024 {
17025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17026 return qe_invalid;
17027 472 }
17028
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17029 return qe_invalid;
17030
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17031 return qe_invalid;
17032 118 }
17033
2/2
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 296 times.
5234 if(scr_has_flags & SCRHAS_WARPRET)
17034 {
17035
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17036 {
17037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17038 return qe_invalid;
17039 1184 }
17040
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17041 {
17042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17043 return qe_invalid;
17044 1184 }
17045
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17046 return qe_invalid;
17047
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17048 return qe_invalid;
17049 296 }
17050
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 4204 times.
5234 if(scr_has_flags & SCRHAS_LAYERS)
17051 {
17052
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17053 {
17054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17055 return qe_invalid;
17056 6180 }
17057
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17058 {
17059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17060 return qe_invalid;
17061 6180 }
17062
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17063 {
17064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17065 return qe_invalid;
17066 6180 }
17067
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17068 return qe_invalid;
17069
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17070 return qe_invalid;
17071 1030 }
17072 else
17073 {
17074
2/2
✓ Branch 0 taken 25224 times.
✓ Branch 1 taken 4204 times.
29428 for(int32_t k=0; k<6; k++)
17075 {
17076 25224 temp_mapscr->layeropacity[k] = 255;
17077 25224 }
17078 }
17079
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_MAZE)
17080 {
17081 for(int32_t k=0; k<4; k++)
17082 {
17083 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17084 return qe_invalid;
17085 }
17086 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17087 return qe_invalid;
17088 }
17089
2/2
✓ Branch 0 taken 5138 times.
✓ Branch 1 taken 96 times.
5234 if(scr_has_flags & SCRHAS_D_S_U)
17090 {
17091
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17092 return qe_invalid;
17093
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 96 times.
480 for(int32_t k=0; k<4; k++)
17094 {
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17096 return qe_invalid;
17097 384 }
17098
17099
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairx),f,true))
17100 return qe_invalid;
17101
17102
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairy),f,true))
17103 return qe_invalid;
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->undercset),f,true))
17107 return qe_invalid;
17108 96 }
17109
2/2
✓ Branch 0 taken 4877 times.
✓ Branch 1 taken 357 times.
5234 if(scr_has_flags & SCRHAS_FLAGS)
17110 {
17111
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags),f,true))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags2),f,true))
17114 return qe_invalid;
17115
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags3),f,true))
17116 return qe_invalid;
17117
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags4),f,true))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags5),f,true))
17120 return qe_invalid;
17121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->flags6),f,true))
17122 return qe_invalid;
17123
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags7),f,true))
17124 return qe_invalid;
17125
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags8),f,true))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags9),f,true))
17128 return qe_invalid;
17129
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags10),f,true))
17130 return qe_invalid;
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17132 return qe_invalid;
17133 357 }
17134
2/2
✓ Branch 0 taken 4916 times.
✓ Branch 1 taken 318 times.
5234 if(scr_has_flags & SCRHAS_ENEMY)
17135 {
17136
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17137 {
17138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17139 return qe_invalid;
17140
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17141 temp_mapscr->enemy[k] = 0;
17142 3180 }
17143
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17144 return qe_invalid;
17145 318 }
17146
2/2
✓ Branch 0 taken 5203 times.
✓ Branch 1 taken 31 times.
5234 if(scr_has_flags & SCRHAS_CARRY)
17147 {
17148
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17149 return qe_invalid;
17150
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17151 return qe_invalid;
17152
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17153 return qe_invalid;
17154
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17155 return qe_invalid;
17156 31 }
17157
2/2
✓ Branch 0 taken 5210 times.
✓ Branch 1 taken 24 times.
5234 if(scr_has_flags & SCRHAS_SCRIPT)
17158 {
17159
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17160 return qe_invalid;
17161
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17162 return qe_invalid;
17163
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17164 {
17165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17166 return qe_invalid;
17167 192 }
17168 24 }
17169
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_UNUSED)
17170 {
17171 for ( int32_t q = 0; q < 10; q++ )
17172 {
17173 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17174 return qe_invalid;
17175 }
17176 for ( int32_t q = 0; q < 10; q++ )
17177 {
17178 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17179 return qe_invalid;
17180 }
17181 for ( int32_t q = 0; q < 10; q++ )
17182 {
17183 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17184 return qe_invalid;
17185 }
17186 for ( int32_t q = 0; q < 10; q++ )
17187 {
17188 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17189 return qe_invalid;
17190 }
17191 }
17192
2/2
✓ Branch 0 taken 4889 times.
✓ Branch 1 taken 345 times.
5234 if(scr_has_flags & SCRHAS_SECRETS)
17193 {
17194
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17195 {
17196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17197 return qe_invalid;
17198 44160 }
17199
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17200 {
17201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17202 return qe_invalid;
17203 44160 }
17204
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17205 {
17206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17207 return qe_invalid;
17208 44160 }
17209 345 }
17210
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2375 times.
5234 if(scr_has_flags & SCRHAS_COMBOFLAG)
17211 {
17212
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17213 {
17214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17215 return qe_invalid;
17216 418000 }
17217
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17218 {
17219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17220 return qe_invalid;
17221 418000 }
17222
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17223 {
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17225 return qe_invalid;
17226 418000 }
17227 2375 }
17228
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 2 times.
5234 if(scr_has_flags & SCRHAS_MISC)
17229 {
17230
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->color),f,true))
17231 return qe_invalid;
17232
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17233 return qe_invalid;
17234
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17235 return qe_invalid;
17236
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17237 return qe_invalid;
17238
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17239 return qe_invalid;
17240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5232 times.
5232 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17241 return qe_invalid;
17242
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17243 return qe_invalid;
17244
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17245 return qe_invalid;
17246
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17247 return qe_invalid;
17248 5232 }
17249 else
17250 {
17251 2 temp_mapscr->screen_midi = -1;
17252 2 temp_mapscr->csensitive = 1;
17253 }
17254 //FFC
17255 5234 bool old_ff = version < 25;
17256 5234 dword bits = 0;
17257 5234 word numffc = 32;
17258
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 5157 times.
5234 if(old_ff)
17259 {
17260
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetl(&bits,f,true))
17261 return qe_invalid;
17262 77 }
17263 else
17264 {
17265
1/2
✓ Branch 0 taken 5157 times.
✗ Branch 1 not taken.
5157 if(!p_igetw(&numffc,f,true))
17266 return qe_invalid;
17267 }
17268 byte tempbyte;
17269 word tempw;
17270
4/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 5215 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19 times.
5234 static ffcdata nil_ffc;
17271 5234 temp_mapscr->ffcCountMarkDirty();
17272
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 8545 times.
13779 for(word m = 0; m < numffc; ++m)
17273 {
17274
1/2
✓ Branch 0 taken 8545 times.
✗ Branch 1 not taken.
8545 ffcdata& tempffc = (m < MAXFFCS)
17275 8545 ? temp_mapscr->ffcs[m]
17276 : nil_ffc; //sanity
17277 8545 tempffc.clear();
17278
3/4
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 6081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
8545 if(old_ff && !(bits & (1<<m))) continue;
17279
17280
1/2
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
6081 if(!p_igetw(&tempw,f,true))
17281 return qe_invalid;
17282
3/4
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5116 times.
6081 if(!old_ff && !tempw) //empty ffc, nothing more to load
17283 5116 continue;
17284 965 tempffc.setData(tempw);
17285
17286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17287 return qe_invalid;
17288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17289 return qe_invalid;
17290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17291 return qe_invalid;
17292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17293 return qe_invalid;
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17295 return qe_invalid;
17296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17297 return qe_invalid;
17298
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17299 return qe_invalid;
17300
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17301 return qe_invalid;
17302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17303 return qe_invalid;
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17305 {
17306 if(!p_getc(&tempbyte,f,true))
17307 return qe_invalid;
17308 tempffc.hxsz = (tempbyte&0x3F)+1;
17309 tempffc.txsz = (tempbyte>>6)+1;
17310 if(!p_getc(&tempbyte,f,true))
17311 return qe_invalid;
17312 tempffc.hysz = (tempbyte&0x3F)+1;
17313 tempffc.tysz = (tempbyte>>6)+1;
17314 }
17315 else
17316 {
17317
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17318 return qe_invalid;
17319
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17320 return qe_invalid;
17321
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17322 return qe_invalid;
17323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17324 return qe_invalid;
17325 }
17326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17327 return qe_invalid;
17328 965 tempffc.updateSolid();
17329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17330 return qe_invalid;
17331
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17332 {
17333
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17334 return qe_invalid;
17335 7720 }
17336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17337 return qe_invalid;
17338 965 tempffc.inita[0]=tempbyte*10000;
17339
17340
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17341 return qe_invalid;
17342 965 tempffc.inita[1]=tempbyte*10000;
17343
17344 965 tempffc.initialized = false;
17345 965 }
17346
2/2
✓ Branch 0 taken 661407 times.
✓ Branch 1 taken 5234 times.
666641 for(word m = numffc; m < MAXFFCS; ++m)
17347 {
17348 661407 temp_mapscr->ffcs[m].clear();
17349 661407 }
17350 //END FFC
17351 }
17352 150210 return 0;
17353 157216 }
17354
17355
17356 99 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17357 {
17358 99 int32_t scr=0;
17359
17360 99 word version=0;
17361 dword dummy;
17362 int32_t screens_to_read;
17363
17364 99 mapscr temp_mapscr;
17365 zcmap temp_map;
17366 word temp_map_count;
17367 dword section_size;
17368
17369
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17370 {
17371 screens_to_read=MAPSCRS192b136;
17372 }
17373 else
17374 {
17375 99 screens_to_read=MAPSCRS;
17376 }
17377
17378
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
17379 {
17380 //section version info
17381
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&version,f,true))
17382 {
17383 return qe_invalid;
17384 }
17385
17386 99 FFCore.quest_format[vMaps] = version;
17387
17388 //al_trace("Maps version %d\n", version);
17389
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
17390 {
17391 return qe_invalid;
17392 }
17393
17394 //section size
17395
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
17396 {
17397 return qe_invalid;
17398 }
17399
17400 //finally... section data
17401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&temp_map_count,f,true))
17402 {
17403 return 5;
17404 }
17405 99 }
17406 else
17407 {
17408 temp_map_count=map_count;
17409 }
17410
17411
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17413 {
17414 99 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17415 99 TheMaps.resize(_mapsSize);
17416
17417
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 99 times.
158267 for(int32_t i(0); i<_mapsSize; i++)
17418 158168 TheMaps[i].zero_memory();
17419
17420 // Used to be done for each screen
17421
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 99 times.
12771 for(int32_t i=0; i<MAXFFCS; i++)
17422 {
17423 12672 ffcScriptData[i].a[0] = 10000;
17424 12672 ffcScriptData[i].a[1] = 10000;
17425 12672 }
17426
17427 99 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17428 99 }
17429
17430 99 temp_mapscr.zero_memory();
17431
17432 99 memset(&temp_map, 0, sizeof(zcmap));
17433 99 temp_map.scrResWidth = 256;
17434 99 temp_map.scrResHeight = 224;
17435 99 temp_map.tileWidth = 16;
17436 99 temp_map.tileHeight = 11;
17437 99 temp_map.viewWidth = 256;
17438 99 temp_map.viewHeight = 176;
17439 99 temp_map.viewX = 0;
17440 99 temp_map.viewY = 64;
17441 99 temp_map.subaWidth = 256;
17442 99 temp_map.subaHeight = 168;
17443 99 temp_map.subaTrans = false;
17444 99 temp_map.subpWidth = 256;
17445 99 temp_map.subpHeight = 56;
17446 99 temp_map.subpTrans = false;
17447
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1163 times.
✓ Branch 2 taken 1163 times.
✓ Branch 3 taken 99 times.
1262 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17448 {
17449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true) //!TODO Trim fully
17450 {
17451 1163 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17452 1163 }
17453 1163 byte valid=1;
17454
2/2
✓ Branch 0 taken 1066 times.
✓ Branch 1 taken 97 times.
1163 if(version > 22)
17455 {
17456
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&valid,f,true))
17457 return qe_invalid;
17458 97 }
17459
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 1163 times.
159331 for(int32_t j=0; j<screens_to_read; j++)
17460 {
17461 158168 scr=i*MAPSCRS+j;
17462 158168 clear_screen(&temp_mapscr);
17463
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 157216 times.
158168 if(valid)
17464 157216 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17465
17466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158168 times.
158168 if(keepdata==true)
17467 {
17468 158168 TheMaps[scr] = temp_mapscr;
17469 158168 }
17470 158168 }
17471
17472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true)
17473 {
17474
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17475 {
17476 int32_t index = (i*MAPSCRS+132);
17477
17478 TheMaps[index]=TheMaps[index-1];
17479
17480 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17481 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17482 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17483
17484 for(int32_t j=133; j<MAPSCRS; j++)
17485 {
17486 scr=i*MAPSCRS+j;
17487
17488 TheMaps[scr].zero_memory();
17489 TheMaps[scr].valid = mVERSION;
17490 TheMaps[scr].screen_midi = -1;
17491 TheMaps[scr].csensitive = 1;
17492 }
17493 }
17494
17495
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17496 {
17497 for(int32_t j=0; j<MAPSCRS; j++)
17498 {
17499 scr=i*MAPSCRS+j;
17500 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17501
17502 for(int32_t k=0; k<128; k++)
17503 {
17504 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17505 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17506 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17507 }
17508 }
17509 }
17510 1163 }
17511 1163 }
17512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17513 {
17514 99 map_count = temp_map_count;
17515 99 }
17516 99 clear_screen(&temp_mapscr);
17517 99 return 0;
17518 99 }
17519
17520
17521 79 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17522 {
17523 79 reset_combo_animations();
17524 79 reset_combo_animations2();
17525
17526 79 init_combo_classes();
17527
17528 // combos
17529 79 word combos_used=0;
17530 int32_t dummy;
17531 byte padding;
17532 79 newcombo temp_combo;
17533 //word section_cversion=0;
17534
17535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
17536 {
17537
2/2
✓ Branch 0 taken 5157120 times.
✓ Branch 1 taken 79 times.
5157199 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17538 5157120 combobuf[q].clear();
17539 79 }
17540
17541 // if(version > 0x192)
17542 // {
17543 // //section version info
17544 // if(!p_igetw(&section_version,f,true))
17545 // {
17546 // return qe_invalid;
17547 // }
17548
17549 // FFCore.quest_format[vCombos] = section_version;
17550
17551 // //al_trace("Combos version %d\n", section_version);
17552 // if(!p_igetw(&section_cversion,f,true))
17553 // {
17554 // return qe_invalid;
17555 // }
17556
17557 // //section size
17558 // if(!p_igetl(&dummy,f,true))
17559 // {
17560 // return qe_invalid;
17561 // }
17562 // }
17563
17564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(version < 0x174)
17565 {
17566 combos_used=1024;
17567 }
17568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 else if(version < 0x191)
17569 {
17570 combos_used=2048;
17571 }
17572 else
17573 {
17574
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&combos_used,f,true))
17575 {
17576 return qe_invalid;
17577 }
17578 }
17579
17580 //finally... section data
17581
2/2
✓ Branch 0 taken 367401 times.
✓ Branch 1 taken 79 times.
367480 for(int32_t i=0; i<combos_used; i++)
17582 {
17583 367401 temp_combo.clear();
17584
17585
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if ( section_version >= 11 )
17586 {
17587
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17588 {
17589 return qe_invalid;
17590 }
17591 68884 }
17592 else
17593 {
17594
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 if(!p_igetw(&temp_combo.tile,f,true))
17595 {
17596 return qe_invalid;
17597 }
17598 }
17599 367401 temp_combo.o_tile = temp_combo.tile;
17600
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.flip,f,true))
17601 {
17602 return qe_invalid;
17603 }
17604
17605
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.walk,f,true))
17606 {
17607 return qe_invalid;
17608 }
17609
17610
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.type,f,true))
17611 {
17612 return qe_invalid;
17613 }
17614
17615
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.csets,f,true))
17616 {
17617 return qe_invalid;
17618 }
17619
17620
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
17621 {
17622 if(!p_getc(&padding,f,true))
17623 return qe_invalid;
17624
17625 if(!p_getc(&padding,f,true))
17626 return qe_invalid;
17627
17628 if(version < 0x192)
17629 {
17630 if(version == 0x191)
17631 {
17632 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17633 {
17634 if(!p_getc(&padding,f,true))
17635 return qe_invalid;
17636 }
17637 }
17638 }
17639 }
17640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(version >= 0x192)
17641 {
17642
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.frames,f,true))
17643 return qe_invalid;
17644
17645
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.speed,f,true))
17646 return qe_invalid;
17647
17648
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_igetw(&temp_combo.nextcombo,f,true))
17649 return qe_invalid;
17650
17651
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.nextcset,f,true))
17652 return qe_invalid;
17653
17654 //Base flag
17655
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=3)
17656
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.flag,f,true))
17657 return qe_invalid;
17658
17659
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=4)
17660 {
17661
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanim,f,true))
17662 return qe_invalid;
17663
17664
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_igetw(&temp_combo.nexttimer,f,true))
17665 return qe_invalid;
17666 360207 }
17667
17668
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=5)
17669
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanimy,f,true))
17670 return qe_invalid;
17671
17672
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=6)
17673 {
17674
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.animflags,f,true))
17675 return qe_invalid;
17676
17677
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(section_version == 6)
17678 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17679 360207 }
17680
17681
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=8) //combo Attributes[4] and userflags.
17682 {
17683
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17684
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17685 return qe_invalid;
17686
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17687 return qe_invalid;
17688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(section_version >= 20)
17689
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17690 return qe_invalid;
17691 68884 }
17692
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=10) //combo trigger flags
17693 {
17694
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17695
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17696 return qe_invalid;
17697 68884 }
17698
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17699 {
17700 for ( int32_t q = 0; q < 2; q++ )
17701 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17702 return qe_invalid;
17703 }
17704
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 9)
17705
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17706 return qe_invalid;
17707
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 22)
17708
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17709 return qe_invalid;
17710
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 24)
17711 {
17712 if(!p_getc(&temp_combo.triggeritem,f,true))
17713 return qe_invalid;
17714 if(!p_getc(&temp_combo.trigtimer,f,true))
17715 return qe_invalid;
17716 }
17717
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 25)
17718 if(!p_getc(&temp_combo.trigsfx,f,true))
17719 return qe_invalid;
17720
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 27)
17721 if(!p_igetl(&temp_combo.trigchange,f,true))
17722 return qe_invalid;
17723
17724
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 29)
17725 {
17726 if(!p_igetw(&temp_combo.trigprox,f,true))
17727 return qe_invalid;
17728 if(!p_getc(&temp_combo.trigctr,f,true))
17729 return qe_invalid;
17730 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17731 return qe_invalid;
17732 }
17733
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 30)
17734 if(!p_getc(&temp_combo.triglbeam,f,true))
17735 return qe_invalid;
17736
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 31)
17737 {
17738 if(!p_getc(&temp_combo.trigcschange,f,true))
17739 return qe_invalid;
17740 if(!p_igetw(&temp_combo.spawnitem,f,true))
17741 return qe_invalid;
17742 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17743 return qe_invalid;
17744 if(!p_getc(&temp_combo.exstate,f,true))
17745 return qe_invalid;
17746 if(!p_igetl(&temp_combo.spawnip,f,true))
17747 return qe_invalid;
17748 if(!p_getc(&temp_combo.trigcopycat,f,true))
17749 return qe_invalid;
17750 }
17751
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 32)
17752 if(!p_getc(&temp_combo.trigcooldown,f,true))
17753 return qe_invalid;
17754
17755
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=12) //combo label
17756
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17757
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17758 68884 return qe_invalid;
17759
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=13) //attribytes[4]
17760
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17761
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17762 68884 return qe_invalid;
17763 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17764 * This fixes a poor implementation of a ->next flag bug thing.
17765 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17766 * there was a version bump a few weeks before a change that broke stuff.
17767 */
17768
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
367401 if (section_version >= 13 && section_version < 21)
17769 {
17770 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17771 }
17772 //combo scripts
17773
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=14)
17774 {
17775
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17776 return qe_invalid;
17777
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17778
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17779 return qe_invalid;
17780 68884 }
17781 //al_trace("Read combo script data\n");
17782
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=15)
17783 {
17784
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17785
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17786
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17788 68884 }
17789
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=17) //attribytes[4]
17790 {
17791
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17792
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17793 return qe_invalid;
17794
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17795
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17796 return qe_invalid;
17797 68884 }
17798
17799
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
17800 for(int32_t q=0; q<11; q++)
17801 if(!p_getc(&dummy,f,true))
17802 return qe_invalid;
17803 367401 }
17804
17805 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17806
3/6
✓ Branch 0 taken 360207 times.
✓ Branch 1 taken 7194 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
367401 if((version < 0x211)||((version == 0x211)&&(build<7)))
17807 {
17808
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17809 {
17810 switch(temp_combo.tile)
17811 {
17812 case 130:
17813 temp_combo.tile = 132;
17814 break;
17815
17816 case 131:
17817 temp_combo.tile = 133;
17818 break;
17819
17820 case 132:
17821 temp_combo.tile = 130;
17822 break;
17823
17824 case 133:
17825 temp_combo.tile = 131;
17826 break;
17827 }
17828 }
17829 7194 }
17830
17831
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version < 15)
17832 298517 temp_combo.o_tile = temp_combo.tile;
17833
17834
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<18) //upper bits for .walk
17835 298517 temp_combo.walk |= 0xF0;
17836
17837
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version < 19)
17838
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for(int32_t q = 0; q < 4; ++q)
17839 1492585 temp_combo.attributes[q] *= 10000L;
17840
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 23)
17842 {
17843
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 367253 times.
367401 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17844 {
17845 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17846 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17847 case cTRIGGERGENERIC: case cCSWITCH:
17848 148 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17849 148 }
17850 367401 }
17851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 25)
17852 {
17853
2/2
✓ Branch 0 taken 2517 times.
✓ Branch 1 taken 364884 times.
367401 switch(temp_combo.type)
17854 {
17855 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2517 times.
2517 if(!(temp_combo.usrflags & cflag3))
17857 2517 temp_combo.attribytes[3] = WAV_DOOR;
17858 2517 temp_combo.usrflags &= ~cflag3;
17859 2517 break;
17860 }
17861 367401 }
17862
17863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 26)
17864
2/2
✓ Branch 0 taken 366902 times.
✓ Branch 1 taken 499 times.
367900 if(temp_combo.type == cARMOS)
17865
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(temp_combo.usrflags & cflag1)
17866 temp_combo.usrflags |= cflag3;
17867
17868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 27)
17869 {
17870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17871 temp_combo.trigchange = 1;
17872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17873 temp_combo.trigchange = -1;
17874 367401 else temp_combo.trigchange = 0;
17875 367401 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17876 367401 }
17877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 28)
17878 {
17879
2/2
✓ Branch 0 taken 1316 times.
✓ Branch 1 taken 366085 times.
367401 switch(temp_combo.type)
17880 {
17881 case cLOCKBLOCK: case cLOCKEDCHEST:
17882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
1316 if(temp_combo.usrflags & cflag7)
17883 temp_combo.usrflags |= cflag8;
17884 1316 else temp_combo.usrflags &= ~cflag8;
17885 1316 temp_combo.usrflags &= ~cflag7;
17886 1316 break;
17887 }
17888
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 367332 times.
367401 switch(temp_combo.type)
17889 {
17890 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17891 69 temp_combo.attrishorts[2] = -1;
17892 69 temp_combo.usrflags |= cflag7;
17893 69 break;
17894 }
17895 367401 }
17896
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version < 20)
17897 {
17898 298517 temp_combo.genflags = 0;
17899
2/2
✓ Branch 0 taken 16849 times.
✓ Branch 1 taken 281668 times.
298517 switch(temp_combo.type)
17900 {
17901 case cPUSH_WAIT: case cPUSH_HEAVY:
17902 case cPUSH_HW: case cL_STATUE:
17903 case cR_STATUE: case cPUSH_HEAVY2:
17904 case cPUSH_HW2: case cPOUND:
17905 case cC_STATUE: case cMIRROR:
17906 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17907 case cMAGICPRISM: case cMAGICPRISM4:
17908 case cMAGICSPONGE: case cEYEBALL_A:
17909 case cEYEBALL_B: case cEYEBALL_4:
17910 case cBUSH: case cFLOWERS:
17911 case cLOCKBLOCK: case cLOCKBLOCK2:
17912 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17913 case cCHEST: case cCHEST2:
17914 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17915 case cBOSSCHEST: case cBOSSCHEST2:
17916 case cBUSHNEXT: case cBUSHTOUCHY:
17917 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17918 case cSIGNPOST: case cCSWITCHBLOCK:
17919 case cTORCH: case cTRIGGERGENERIC:
17920
1/2
✓ Branch 0 taken 16849 times.
✗ Branch 1 not taken.
16849 if(temp_combo.usrflags & cflag16)
17921 {
17922 temp_combo.genflags |= cflag1;
17923 temp_combo.usrflags &= ~cflag16;
17924 }
17925 16849 break;
17926 }
17927 298517 }
17928
17929
2/4
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 367401 times.
367401 if(keepdata==true && i>=start_combo)
17930 {
17931 367401 combobuf[i] = temp_combo;
17932 367401 }
17933 367401 }
17934
17935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
17936 {
17937
2/6
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17938 {
17939 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17940 {
17941 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17942 {
17943 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17944 }
17945 }
17946 }
17947
17948 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17949
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(version == 0x210 && !is_zquest())
17950 {
17951
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17952
1/2
✓ Branch 0 taken 195840 times.
✗ Branch 1 not taken.
195840 if(combobuf[tmpcounter].type == cLADDERONLY)
17953 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17954 3 }
17955
17956
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 3 times.
79 if(section_version<7)
17957 {
17958
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17959 {
17960
2/9
✓ Branch 0 taken 195837 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
195840 switch(combobuf[tmpcounter].type)
17961 {
17962 case cSLASH:
17963 3 combobuf[tmpcounter].type=cSLASHTOUCHY;
17964 3 break;
17965
17966 case cSLASHITEM:
17967 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17968 break;
17969
17970 case cBUSH:
17971 combobuf[tmpcounter].type=cBUSHTOUCHY;
17972 break;
17973
17974 case cFLOWERS:
17975 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17976 break;
17977
17978 case cTALLGRASS:
17979 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17980 break;
17981
17982 case cSLASHNEXT:
17983 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17984 break;
17985
17986 case cSLASHNEXTITEM:
17987 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17988 break;
17989
17990 case cBUSHNEXT:
17991 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17992 break;
17993 }
17994 195840 }
17995 3 }
17996
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77 times.
79 if (section_version < 16)
17997 {
17998
2/2
✓ Branch 0 taken 5026560 times.
✓ Branch 1 taken 77 times.
5026637 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17999 {
18000
2/2
✓ Branch 0 taken 5022039 times.
✓ Branch 1 taken 4521 times.
5026560 if (combobuf[tmpcounter].type == cWATER)
18001 {
18002 4521 combobuf[tmpcounter].attributes[0] = 40000L;
18003 4521 }
18004 5026560 }
18005 77 }
18006
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
79 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18007 {
18008 1 combobuf[0].walk = 0xF0;
18009 1 combobuf[0].type = 0;
18010 1 combobuf[0].flag = 0;
18011 1 }
18012 79 }
18013
18014 //Now for the new combo alias reset
18015
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(section_version<2 && keepdata)
18016 {
18017
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 3 times.
24579 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18018 {
18019 24576 combo_aliases[j].width = 0;
18020 24576 combo_aliases[j].height = 0;
18021 24576 combo_aliases[j].layermask = 0;
18022
18023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].combos != NULL)
18024 {
18025
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 delete[] combo_aliases[j].combos;
18026 24576 }
18027
18028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].csets != NULL)
18029 {
18030
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 delete[] combo_aliases[j].csets;
18031 24576 }
18032
18033 24576 combo_aliases[j].combos = new word[1];
18034 24576 combo_aliases[j].csets = new byte[1];
18035 24576 combo_aliases[j].combos[0] = 0;
18036 24576 combo_aliases[j].csets[0] = 0;
18037 24576 }
18038 3 }
18039
18040
18041 79 setup_combo_animations();
18042 79 setup_combo_animations2();
18043 79 return 0;
18044 79 }
18045 131498 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18046 {
18047 byte combo_has_flags;
18048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131498 times.
131498 if(!p_getc(&combo_has_flags,f,true))
18049 return qe_invalid;
18050
18051 131498 temp_combo.clear();
18052
2/2
✓ Branch 0 taken 84766 times.
✓ Branch 1 taken 46732 times.
131498 if(combo_has_flags)
18053 {
18054
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 46729 times.
46732 if(combo_has_flags&CHAS_GENERAL)
18055 {
18056
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_igetl(&temp_combo.tile,f,true))
18057 {
18058 return qe_invalid;
18059 }
18060 46729 temp_combo.o_tile = temp_combo.tile;
18061
18062
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flip,f,true))
18063 {
18064 return qe_invalid;
18065 }
18066
18067
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.walk,f,true))
18068 {
18069 return qe_invalid;
18070 }
18071
18072
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.type,f,true))
18073 {
18074 return qe_invalid;
18075 }
18076
18077
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flag,f,true))
18078 {
18079 return qe_invalid;
18080 }
18081
18082
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.csets,f,true))
18083 {
18084 return qe_invalid;
18085 }
18086 46729 }
18087
2/2
✓ Branch 0 taken 46716 times.
✓ Branch 1 taken 16 times.
46732 if(combo_has_flags&CHAS_SCRIPT)
18088 {
18089
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 for ( int32_t q = 0; q < 11; q++ )
18090 {
18091
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&temp_combo.label[q],f,true))
18092 {
18093 return qe_invalid;
18094 }
18095 176 }
18096
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18097
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
48 for ( int32_t q = 0; q < 2; q++ )
18098 {
18099
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetl(&temp_combo.initd[q],f,true))
18100 {
18101 return qe_invalid;
18102 }
18103 32 }
18104 16 }
18105
2/2
✓ Branch 0 taken 33663 times.
✓ Branch 1 taken 13069 times.
46732 if(combo_has_flags&CHAS_ANIM)
18106 {
18107
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.frames,f,true))
18108 {
18109 return qe_invalid;
18110 }
18111
18112
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.speed,f,true))
18113 {
18114 return qe_invalid;
18115 }
18116
18117
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_igetw(&temp_combo.nextcombo,f,true))
18118 {
18119 return qe_invalid;
18120 }
18121
18122
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.nextcset,f,true))
18123 {
18124 return qe_invalid;
18125 }
18126
18127
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanim,f,true))
18128 {
18129 return qe_invalid;
18130 }
18131
18132
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanimy,f,true))
18133 {
18134 return qe_invalid;
18135 }
18136
18137
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.animflags,f,true))
18138 {
18139 return qe_invalid;
18140 }
18141 13069 }
18142
2/2
✓ Branch 0 taken 42653 times.
✓ Branch 1 taken 4079 times.
46732 if(combo_has_flags&CHAS_ATTRIB)
18143 {
18144
2/2
✓ Branch 0 taken 16316 times.
✓ Branch 1 taken 4079 times.
20395 for ( int32_t q = 0; q < 4; q++ )
18145 {
18146
1/2
✓ Branch 0 taken 16316 times.
✗ Branch 1 not taken.
16316 if(!p_igetl(&temp_combo.attributes[q],f,true))
18147 {
18148 return qe_invalid;
18149 }
18150 16316 }
18151
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18152 {
18153
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_getc(&temp_combo.attribytes[q],f,true))
18154 {
18155 return qe_invalid;
18156 }
18157 32632 }
18158
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18159 {
18160
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18161 {
18162 return qe_invalid;
18163 }
18164 32632 }
18165 4079 }
18166
2/2
✓ Branch 0 taken 45433 times.
✓ Branch 1 taken 1299 times.
46732 if(combo_has_flags&CHAS_FLAG)
18167 {
18168
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetl(&temp_combo.usrflags,f,true))
18169 {
18170 return qe_invalid;
18171 }
18172
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetw(&temp_combo.genflags,f,true))
18173 {
18174 return qe_invalid;
18175 }
18176 1299 }
18177
2/2
✓ Branch 0 taken 46405 times.
✓ Branch 1 taken 327 times.
46732 if(combo_has_flags&CHAS_TRIG)
18178 {
18179
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 327 times.
1308 for ( int32_t q = 0; q < 3; q++ )
18180 {
18181
1/2
✓ Branch 0 taken 981 times.
✗ Branch 1 not taken.
981 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18182 {
18183 return qe_invalid;
18184 }
18185 981 }
18186
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18187 {
18188 return qe_invalid;
18189 }
18190
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggerbtn,f,true))
18191 {
18192 return qe_invalid;
18193 }
18194
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggeritem,f,true))
18195 {
18196 return qe_invalid;
18197 }
18198
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigtimer,f,true))
18199 {
18200 return qe_invalid;
18201 }
18202
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigsfx,f,true))
18203 {
18204 return qe_invalid;
18205 }
18206
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigchange,f,true))
18207 {
18208 return qe_invalid;
18209 }
18210
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.trigprox,f,true))
18211 {
18212 return qe_invalid;
18213 }
18214
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigctr,f,true))
18215 {
18216 return qe_invalid;
18217 }
18218
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18219 {
18220 return qe_invalid;
18221 }
18222
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triglbeam,f,true))
18223 {
18224 return qe_invalid;
18225 }
18226
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcschange,f,true))
18227 {
18228 return qe_invalid;
18229 }
18230
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnitem,f,true))
18231 {
18232 return qe_invalid;
18233 }
18234
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18235 {
18236 return qe_invalid;
18237 }
18238
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.exstate,f,true))
18239 {
18240 return qe_invalid;
18241 }
18242
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.spawnip,f,true))
18243 {
18244 return qe_invalid;
18245 }
18246
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcopycat,f,true))
18247 {
18248 return qe_invalid;
18249 }
18250
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcooldown,f,true))
18251 {
18252 return qe_invalid;
18253 }
18254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(s_version >= 35)
18255 {
18256
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18257 {
18258 return qe_invalid;
18259 }
18260
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.prompt_cs,f,true))
18261 {
18262 return qe_invalid;
18263 }
18264
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_x,f,true))
18265 {
18266 return qe_invalid;
18267 }
18268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(!p_igetw(&temp_combo.prompt_y,f,true))
18269 {
18270 return qe_invalid;
18271 }
18272 327 }
18273 327 }
18274
2/2
✓ Branch 0 taken 46657 times.
✓ Branch 1 taken 75 times.
46732 if(combo_has_flags&CHAS_LIFT)
18275 {
18276
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftcmb,f,true))
18277 return qe_invalid;
18278
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftcs,f,true))
18279 return qe_invalid;
18280
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18281 return qe_invalid;
18282
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftundercs,f,true))
18283 return qe_invalid;
18284
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftdmg,f,true))
18285 return qe_invalid;
18286
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftlvl,f,true))
18287 return qe_invalid;
18288
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftitm,f,true))
18289 return qe_invalid;
18290
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftflags,f,true))
18291 return qe_invalid;
18292
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftgfx,f,true))
18293 return qe_invalid;
18294
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsprite,f,true))
18295 return qe_invalid;
18296
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsfx,f,true))
18297 return qe_invalid;
18298
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18299 return qe_invalid;
18300
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18301 return qe_invalid;
18302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(s_version >= 34)
18303 {
18304
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifthei,f,true))
18305 return qe_invalid;
18306
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifttime,f,true))
18307 return qe_invalid;
18308 75 }
18309 75 }
18310 46732 }
18311 131498 return 0;
18312 131498 }
18313 99 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18314 {
18315 99 word section_version=0;
18316 99 word section_cversion=0;
18317 99 word combos_used=0;
18318 int32_t dummy;
18319 byte padding;
18320 99 newcombo temp_combo;
18321
18322 99 reset_combo_animations();
18323 99 reset_combo_animations2();
18324 99 init_combo_classes();
18325
18326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true) //reset combos
18327 {
18328
2/2
✓ Branch 0 taken 6462720 times.
✓ Branch 1 taken 99 times.
6462819 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18329 6462720 combobuf[q].clear();
18330 99 }
18331
18332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192) //Version info
18333 {
18334
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
18335 {
18336 return qe_invalid;
18337 }
18338 99 FFCore.quest_format[vCombos] = section_version;
18339
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
18340 {
18341 return qe_invalid;
18342 }
18343
18344 //section size
18345
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18346 {
18347 return qe_invalid;
18348 }
18349 99 }
18350
18351
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(section_version > 32) //Cleanup time!
18352 {
18353
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&combos_used,f,true))
18354 {
18355 return qe_invalid;
18356 }
18357
2/2
✓ Branch 0 taken 131498 times.
✓ Branch 1 taken 20 times.
131518 for(int32_t i=0; i<combos_used; i++)
18358 {
18359 131498 auto ret = readcombo_loop(f,section_version,temp_combo);
18360
1/2
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
131498 if(ret) return ret;
18361
2/4
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131498 times.
131498 if(keepdata==true && i>=start_combo)
18362 131498 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18363 131498 }
18364 20 }
18365 else //Call the old function for all old versions
18366 {
18367 79 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(ret) return ret; //error, end read
18369 }
18370
18371
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(keepdata && false/*section_version < 34*/)
18372 {
18373 for(int32_t i=start_combo; i<combos_used; i++)
18374 {
18375 newcombo& cmb = combobuf[i];
18376 //Do anything to 'cmb' needed for version handling
18377 }
18378 }
18379
18380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
18381 {
18382
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18383 {
18384 20 combobuf[0].walk = 0xF0;
18385 20 combobuf[0].type = 0;
18386 20 combobuf[0].flag = 0;
18387 20 }
18388 99 }
18389
18390 99 setup_combo_animations();
18391 99 setup_combo_animations2();
18392 99 return 0;
18393 99 }
18394
18395 96 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18396 {
18397 //these are here to bypass compiler warnings about unused arguments
18398 96 Header=Header;
18399 96 version=version;
18400 96 build=build;
18401
18402 int32_t dummy;
18403 96 word sversion=0, c_sversion;
18404
18405 //section version info
18406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&sversion,f,true))
18407 {
18408 return qe_invalid;
18409 }
18410
18411 96 FFCore.quest_format[vComboAliases] = sversion;
18412
18413 //al_trace("Combo aliases version %d\n", sversion);
18414
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&c_sversion,f,true))
18415 {
18416 return qe_invalid;
18417 }
18418
18419 //section size
18420
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
18421 {
18422 return qe_invalid;
18423 }
18424
18425 96 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18426
18427
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18428 {
18429 74 max_num_combo_aliases = MAX250COMBOALIASES;
18430 74 }
18431
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18432 {
18433 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18434 }
18435
18436
2/2
✓ Branch 0 taken 331776 times.
✓ Branch 1 taken 96 times.
331872 for(int32_t j=0; j<max_num_combo_aliases; j++)
18437 {
18438 byte width,height,mask,tempcset;
18439 int32_t count;
18440 word tempword;
18441 byte tempbyte;
18442
18443
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_igetw(&tempword,f,true))
18444 {
18445 return qe_invalid;
18446 }
18447
18448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18449 {
18450 331776 combo_aliases[j].combo = tempword;
18451 331776 }
18452
18453
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&tempbyte,f,true))
18454 {
18455 return qe_invalid;
18456 }
18457
18458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18459 {
18460 331776 combo_aliases[j].cset = tempbyte;
18461 331776 }
18462
18463
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&width,f,true))
18464 {
18465 return qe_invalid;
18466 }
18467
18468
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&height,f,true))
18469 {
18470 return qe_invalid;
18471 }
18472
18473
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&mask,f,true))
18474 {
18475 return qe_invalid;
18476 }
18477
18478 331776 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18479
18480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18481 {
18482
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].combos != NULL)
18483 {
18484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].combos;
18485 331776 }
18486
18487
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].csets != NULL)
18488 {
18489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].csets;
18490 331776 }
18491
18492 331776 combo_aliases[j].width = width;
18493 331776 combo_aliases[j].height = height;
18494 331776 combo_aliases[j].layermask = mask;
18495 331776 combo_aliases[j].combos = new word[count];
18496 331776 combo_aliases[j].csets = new byte[count];
18497 331776 }
18498
18499
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18500 {
18501
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_igetw(&tempword,f,true))
18502 {
18503 return qe_invalid;
18504 }
18505
18506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18507 {
18508 339765 combo_aliases[j].combos[k] = tempword;
18509 339765 }
18510 339765 }
18511
18512
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18513 {
18514
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_getc(&tempcset,f,true))
18515 {
18516 return qe_invalid;
18517 }
18518
18519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18520 {
18521 339765 combo_aliases[j].csets[k] = tempcset;
18522 339765 }
18523 339765 }
18524 331776 }
18525
18526 96 word num_combo_pools = 0;
18527
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 20 times.
96 if(sversion >= 4)
18528 {
18529
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&num_combo_pools,f,true))
18530 {
18531 return qe_invalid;
18532 }
18533 20 }
18534
18535
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 96 times.
786528 for(combo_pool& pool : combo_pools)
18536 {
18537 786432 pool.clear();
18538 }
18539
18540 96 combo_pool temp_cpool;
18541
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 96 times.
150 for(word cp = 0; cp < num_combo_pools; ++cp)
18542 {
18543 54 int32_t num_combos_in_pool = 0;
18544
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(!p_igetl(&num_combos_in_pool,f,true))
18545 {
18546 return qe_invalid;
18547 }
18548
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(num_combos_in_pool < 1) continue; //nothing to read
18549
18550
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 temp_cpool.clear();
18551
18552 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18553
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 54 times.
288 for(auto q = 0; q < num_combos_in_pool; ++q)
18554 {
18555
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetl(&cp_cid,f,true))
18556 {
18557 return qe_invalid;
18558 }
18559
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_getc(&cp_cs,f,true))
18560 {
18561 return qe_invalid;
18562 }
18563
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetw(&cp_quant,f,true))
18564 {
18565 return qe_invalid;
18566 }
18567
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18568 234 }
18569
18570
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(keepdata)
18571 {
18572
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 combo_pools[cp] = temp_cpool;
18573 54 }
18574 54 }
18575
18576 96 return 0;
18577 96 }
18578
18579 99 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18580 {
18581 //these are here to bypass compiler warnings about unused arguments
18582
18583 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18584 //Capitalized cause it'll save you a headache. -Deedee
18585 99 start_cset=start_cset;
18586 99 max_csets=max_csets;
18587 99 word s_version=0;
18588
18589 miscQdata temp_misc;
18590 99 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18591
18592 byte temp_colordata[48];
18593 char temp_palname[PALNAMESIZE];
18594
18595 int32_t dummy;
18596 word palcycles;
18597
18598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
18599 {
18600 //section version info
18601
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
18602 {
18603 return qe_invalid;
18604 }
18605
18606 99 FFCore.quest_format[vCSets] = s_version;
18607
18608 //al_trace("Color data version %d\n", s_version);
18609
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
18610 {
18611 return qe_invalid;
18612 }
18613
18614 //section size
18615
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18616 {
18617 return qe_invalid;
18618 }
18619 99 }
18620
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if (s_version < 5)
18621 {
18622
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18623
18624 //finally... section data
18625 77 int32_t q = 0;
18626 77 int32_t p = -15;
18627
2/2
✓ Branch 0 taken 18480 times.
✓ Branch 1 taken 77 times.
18557 for(int32_t i=0; i<oldpdTOTAL; ++i)
18628 {
18629 18480 memset(temp_colordata, 0, 48);
18630
18631
1/2
✓ Branch 0 taken 18480 times.
✗ Branch 1 not taken.
18480 if(!pfread(temp_colordata,48,f,true))
18632 {
18633 return qe_invalid;
18634 }
18635
18636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18480 times.
18480 if(keepdata==true)
18637 {
18638 18480 memcpy(&colordata[q*48], temp_colordata, 48);
18639 18480 }
18640 18480 ++q;
18641
7/8
✓ Branch 0 taken 17248 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 1309 times.
✓ Branch 3 taken 15939 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 154 times.
18480 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18642 {
18643
1/2
✓ Branch 0 taken 1309 times.
✗ Branch 1 not taken.
1309 if (s_version < 5) //Bumping up the size of level palettes
18644 {
18645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1309 times.
1309 if(keepdata==true)
18646 {
18647 1309 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18648 1309 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18649 1309 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18650 1309 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18651 1309 }
18652 1309 q+=4;
18653 1309 }
18654 else
18655 {
18656 for(int m = 0; m < 4; ++m)
18657 {
18658 memset(temp_colordata, 0, 48);
18659 if(!pfread(temp_colordata,48,f,true))
18660 {
18661 return qe_invalid;
18662 }
18663 if(keepdata==true)
18664 {
18665 memcpy(&colordata[q*48], temp_colordata, 48);
18666 }
18667 ++q;
18668 }
18669 }
18670 1309 }
18671 18480 ++p;
18672 18480 }
18673
18674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(RealOldVerion)
18675 {
18676 if(keepdata==true)
18677 {
18678 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18679 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18680 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18681 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18682 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18683 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18684 }
18685 }
18686 else
18687 {
18688 77 memset(temp_colordata, 0, 48);
18689
18690
2/2
✓ Branch 0 taken 241241 times.
✓ Branch 1 taken 77 times.
241318 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18691 {
18692
1/2
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
241241 if(!pfread(temp_colordata,48,f,true))
18693 {
18694 return qe_invalid;
18695 }
18696
18697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241241 times.
241241 if(keepdata==true)
18698 {
18699 241241 memcpy(&colordata[q*48], temp_colordata, 48);
18700 241241 }
18701 241241 ++q;
18702
7/8
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✓ Branch 3 taken 222684 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 18403 times.
✓ Branch 6 taken 148 times.
✓ Branch 7 taken 6 times.
241241 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18703 {
18704
1/2
✓ Branch 0 taken 18551 times.
✗ Branch 1 not taken.
18551 if (s_version < 5) //Bumping up the size of level palettes
18705 {
18706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18551 times.
18551 if(keepdata==true)
18707 {
18708 18551 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18709 18551 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18710 18551 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18711 18551 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18712 18551 }
18713 18551 q+=4;
18714 18551 }
18715 else
18716 {
18717 for(int m = 0; m < 4; ++m)
18718 {
18719 memset(temp_colordata, 0, 48);
18720 if(!pfread(temp_colordata,48,f,true))
18721 {
18722 return qe_invalid;
18723 }
18724 if(keepdata==true)
18725 {
18726 memcpy(&colordata[q*48], temp_colordata, 48);
18727 }
18728 ++q;
18729 }
18730 }
18731 18551 }
18732 241241 ++p;
18733 241241 }
18734
18735
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(s_version < 4)
18736 {
18737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata==true)
18738 {
18739 3 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18740 3 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18741 3 }
18742 3 }
18743 else
18744 {
18745
2/2
✓ Branch 0 taken 246272 times.
✓ Branch 1 taken 74 times.
246346 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18746 {
18747
1/2
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
246272 if(!pfread(temp_colordata,48,f,true))
18748 {
18749 return qe_invalid;
18750 }
18751
18752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246272 times.
246272 if(keepdata==true)
18753 {
18754 246272 memcpy(&colordata[q*48], temp_colordata, 48);
18755 246272 }
18756 246272 ++q;
18757
5/6
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✓ Branch 3 taken 227328 times.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 18796 times.
246272 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18758 {
18759
1/2
✓ Branch 0 taken 18796 times.
✗ Branch 1 not taken.
18796 if (s_version < 5) //Bumping up the size of level palettes
18760 {
18761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18796 times.
18796 if(keepdata==true)
18762 {
18763 18796 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18764 18796 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18765 18796 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18766 18796 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18767 18796 }
18768 18796 q+=4;
18769 18796 }
18770 else
18771 {
18772 for(int m = 0; m < 4; ++m)
18773 {
18774 memset(temp_colordata, 0, 48);
18775 if(!pfread(temp_colordata,48,f,true))
18776 {
18777 return qe_invalid;
18778 }
18779 if(keepdata==true)
18780 {
18781 memcpy(&colordata[q*48], temp_colordata, 48);
18782 }
18783 ++q;
18784 }
18785 }
18786 18796 }
18787 246272 ++p;
18788 246272 }
18789
18790 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18791 }
18792 }
18793 77 }
18794 else
18795 {
18796
2/2
✓ Branch 0 taken 192478 times.
✓ Branch 1 taken 22 times.
192500 for(int32_t i=0; i<pdTOTAL255; ++i)
18797 {
18798 192478 memset(temp_colordata, 0, 48);
18799
18800
1/2
✓ Branch 0 taken 192478 times.
✗ Branch 1 not taken.
192478 if(!pfread(temp_colordata,48,f,true))
18801 {
18802 return qe_invalid;
18803 }
18804
18805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192478 times.
192478 if(keepdata==true)
18806 {
18807 192478 memcpy(&colordata[i*48], temp_colordata, 48);
18808 192478 }
18809 192478 }
18810 }
18811
18812
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)||((version == 0x192)&&(build<76)))
18813 {
18814 if(keepdata==true)
18815 {
18816 init_palnames();
18817 }
18818 }
18819 else
18820 {
18821 99 int32_t palnamestoread = 0;
18822
18823
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 3)
18824 3 palnamestoread = OLDMAXLEVELS;
18825 else
18826 96 palnamestoread = 512;
18827
18828
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=0; i<palnamestoread; ++i)
18829 {
18830 49920 memset(temp_palname, 0, PALNAMESIZE);
18831
18832
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(temp_palname,PALNAMESIZE,f,true))
18833 {
18834 return qe_invalid;
18835 }
18836
18837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
18838 {
18839 49920 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18840 49920 }
18841 49920 }
18842
18843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
18844 {
18845
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 99 times.
867 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18846 {
18847 768 memset(palnames[i], 0, PALNAMESIZE);
18848 768 }
18849 99 }
18850 }
18851
18852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
18853 {
18854
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<256; i++)
18855 {
18856
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 25344 times.
101376 for(int32_t j=0; j<3; j++)
18857 {
18858 76032 temp_misc.cycles[i][j].first=0;
18859 76032 temp_misc.cycles[i][j].count=0;
18860 76032 temp_misc.cycles[i][j].speed=0;
18861 76032 }
18862 25344 }
18863
18864
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&palcycles,f,true))
18865 {
18866 return qe_invalid;
18867 }
18868
18869
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 99 times.
3322 for(int32_t i=0; i<palcycles; i++)
18870 {
18871
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
18872 {
18873
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
18874 {
18875 return qe_invalid;
18876 }
18877 9669 }
18878
18879
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
18880 {
18881
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
18882 {
18883 return qe_invalid;
18884 }
18885 9669 }
18886
18887
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
18888 {
18889
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
18890 {
18891 return qe_invalid;
18892 }
18893 9669 }
18894 3223 }
18895
18896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
18897 {
18898 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18899 99 }
18900 99 }
18901
18902 99 return 0;
18903 99 }
18904
18905 99 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
18906 {
18907 99 int32_t tiles_used=0;
18908 99 word section_version = 0;
18909 99 word section_cversion = 0;
18910 99 int32_t section_size= 0;
18911 99 byte *temp_tile = new byte[tilesize(tf32Bit)];
18912
18913 //Tile Expansion
18914 //if ( version >= 0x254 && build >= 41 )
18915
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
99 if (version < 0x254 && build < 41)
18916 {
18917 //al_trace("Build was < 41 when reading tiles\n");
18918 77 max_tiles = ZC250MAXTILES;
18919 77 }
18920
18921 //al_trace("Max Tiles: %d\n", max_tiles);
18922
18923
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18924 {
18925 if(keepdata==true)
18926 {
18927 if(!init_tiles(true, Header))
18928 {
18929 al_trace("Unable to initialize tiles\n");
18930 }
18931 }
18932
18933 delete[] temp_tile;
18934 temp_tile=NULL;
18935 return 0;
18936 }
18937 else
18938 {
18939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
18940 {
18941 //section version info
18942
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
18943 {
18944 delete[] temp_tile;
18945 return qe_invalid;
18946 }
18947
18948 99 FFCore.quest_format[vTiles] = section_version;
18949
18950
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
18951 {
18952 delete[] temp_tile;
18953 return qe_invalid;
18954 }
18955
18956 //section size
18957
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
18958 {
18959 delete[] temp_tile;
18960 return qe_invalid;
18961 }
18962 99 }
18963
18964 //if ( build < 41 )
18965 //{
18966 // tiles_used = ZC250MAXTILES;
18967 //}
18968
18969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version < 0x174)
18970 {
18971 tiles_used=TILES_PER_PAGE*4;
18972 } //no expanded tile space
18973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 else if(version < 0x191)
18974 {
18975 tiles_used=OLDMAXTILES;
18976 }
18977 else
18978 {
18979 //finally... section data
18980
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
99 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18981 {
18982
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tiles_used,f,true))
18983 {
18984 delete[] temp_tile;
18985 return qe_invalid;
18986 }
18987 22 }
18988 else
18989 {
18990
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tiles_used,f,true))
18991 {
18992 delete[] temp_tile;
18993 return qe_invalid;
18994 }
18995 }
18996 }
18997
18998
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 tiles_used=zc_min(tiles_used, max_tiles);
18999
19000 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19001 //if ( version < 0x254 && build < 41 )
19002
3/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if ( version < 0x254 || (version == 0x254 && build < 41) )
19003 //if ( build < 41 )
19004 {
19005
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19006 77 }
19007 else //2.55
19008 {
19009
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19010 }
19011
19012 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19013
19014 //al_trace("tiles_used = %d\n", tiles_used);
19015
19016
2/2
✓ Branch 0 taken 2239372 times.
✓ Branch 1 taken 99 times.
2239471 for(int32_t i=0; i<tiles_used; ++i)
19017 {
19018 2239372 byte format=tf4Bit;
19019 2239372 memset(temp_tile, 0, tilesize(tf32Bit));
19020
19021
3/6
✓ Branch 0 taken 34986 times.
✓ Branch 1 taken 2204386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34986 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2239372 if((version>0x211)||((version==0x211)&&(build>4)))
19022 {
19023
1/2
✓ Branch 0 taken 2204386 times.
✗ Branch 1 not taken.
2204386 if(!p_getc(&format,f,true))
19024 {
19025 delete[] temp_tile;
19026 return qe_invalid;
19027 }
19028 2204386 }
19029
4/4
✓ Branch 0 taken 557954 times.
✓ Branch 1 taken 1681418 times.
✓ Branch 2 taken 276608 times.
✓ Branch 3 taken 281346 times.
2239372 if(section_version > 2 && !format)
19030 {
19031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281346 times.
281346 if(keepdata)
19032 {
19033 281346 reset_tile(buf,start_tile+i,tf4Bit);
19034 281346 }
19035 281346 continue;
19036 }
19037
19038
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(!pfread(temp_tile,tilesize(format),f,true))
19039 {
19040 delete[] temp_tile;
19041 return qe_invalid;
19042 }
19043
19044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1958026 times.
1958026 if(keepdata==true)
19045 {
19046 1958026 buf[start_tile+i].format=format;
19047
19048
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(buf[start_tile+i].data)
19049 {
19050 1958026 free(buf[start_tile+i].data);
19051 1958026 buf[start_tile+i].data=NULL;
19052 1958026 }
19053
19054 1958026 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19055 1958026 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19056 1958026 }
19057 1958026 }
19058 }
19059
19060
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19061 {
19062 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19063
2/2
✓ Branch 0 taken 11471460 times.
✓ Branch 1 taken 77 times.
11471537 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19064 {
19065
19066 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19067 11471460 reset_tile(buf,q,tf4Bit);
19068
19069
19070 /*
19071
19072 byte tempbyte;
19073 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19074 {
19075 tempbyte=buf[ZC250MAXTILES-1].data[i];
19076 buf[q].data[i] = tempbyte;
19077 }
19078 //int32_t temp = tempbyte=buf[130].data[i];
19079 //buf[q].data = buf[ZC250MAXTILES-1].data;
19080 */
19081 //reset_tile(buf,q,tf4Bit);
19082 11471460 }
19083
19084 77 }
19085
19086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19087 {
19088
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19089 {
19090
2/2
✓ Branch 0 taken 3747632 times.
✓ Branch 1 taken 77 times.
3747709 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19091 {
19092 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19093 3747632 reset_tile(buf,i,tf4Bit);
19094 3747632 }
19095 77 }
19096 else
19097 {
19098
2/2
✓ Branch 0 taken 3777036 times.
✓ Branch 1 taken 22 times.
3777058 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19099 {
19100 //al_trace("Resetting tiles for build 41+\n");
19101 3777036 reset_tile(buf,i,tf4Bit);
19102 3777036 }
19103 }
19104
19105
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19106 {
19107 if(get_bit(quest_rules,qr_BSZELDA)) //
19108 {
19109 byte tempbyte;
19110 int32_t floattile=wpnsbuf[iwSwim].tile;
19111
19112 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19113 {
19114 tempbyte=buf[23].data[i];
19115 buf[23].data[i]=buf[24].data[i];
19116 buf[24].data[i]=buf[25].data[i];
19117 buf[25].data[i]=buf[26].data[i];
19118 buf[26].data[i]=tempbyte;
19119 }
19120 //swim tiles are out of order, too, but nobody cared? -Z
19121 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19122 {
19123 tempbyte=buf[floattile+11].data[i];
19124 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19125 buf[floattile+12].data[i]=tempbyte;
19126 }
19127 }
19128 }
19129
19130
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19131 {
19132
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19133 {
19134 byte tempbyte;
19135
19136 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19137 {
19138 tempbyte=buf[130].data[i];
19139 buf[130].data[i]=buf[132].data[i];
19140 buf[132].data[i]=tempbyte;
19141
19142 tempbyte=buf[131].data[i];
19143 buf[131].data[i]=buf[133].data[i];
19144 buf[133].data[i]=tempbyte;
19145 }
19146 }
19147 3 }
19148
19149 99 al_trace("Registering blank tiles\n");
19150 99 register_blank_tiles();
19151 99 }
19152
19153 //memset(temp_tile, 0, tilesize(tf32Bit));
19154
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 delete[] temp_tile;
19155 99 temp_tile=NULL;
19156 99 return 0;
19157 99 }
19158
19159 99 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19160 {
19161 99 byte *mf=midi_flags;
19162 int32_t dummy;
19163 word dummy2;
19164 // zcmidi_ temp_midi;
19165 int32_t tunes_to_read;
19166 99 int32_t tune_count=0;
19167 99 word section_version=0;
19168 99 zctune temp;
19169
19170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
19171 {
19172 // mf=Header->data_flags+ZQ_MIDIS2;
19173 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19174 {
19175 tunes_to_read=MAXCUSTOMMIDIS192b177;
19176 }
19177 else
19178 {
19179 tunes_to_read=MAXCUSTOMTUNES;
19180 }
19181 }
19182 else
19183 {
19184 //section version info
19185
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
19186 {
19187 return qe_invalid;
19188 }
19189
19190 99 FFCore.quest_format[vMIDIs] = section_version;
19191
19192 //al_trace("Tunes version %d\n", section_version);
19193
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy2,f,true))
19194 {
19195 return qe_invalid;
19196 }
19197
19198 //section size
19199
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19200 {
19201 return qe_invalid;
19202 }
19203
19204 //finally... section data
19205
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19206 {
19207 return qe_invalid;
19208 }
19209
19210 99 tunes_to_read=MAXCUSTOMTUNES;
19211 }
19212
19213
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19214 {
19215
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf, i))
19216 {
19217 1629 ++tune_count;
19218 1629 }
19219 24948 }
19220
19221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19222 {
19223 99 reset_tunes(tunes); //reset_midis(midis);
19224 99 }
19225
19226
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<tunes_to_read; i++)
19227 {
19228 24948 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19229
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24948 times.
24948 if(keepdata==true)
19231 {
19232 24948 tunes[i].reset(); // reset_midi(midis+i);
19233 24948 }
19234
19235
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf,i))
19236 {
19237
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 4)
19238 {
19239
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19240 {
19241 return qe_invalid;
19242 }
19243 99 }
19244 else
19245 {
19246
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19247 {
19248 return qe_invalid;
19249 }
19250 }
19251
19252
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.start,f,true))
19253 {
19254 return qe_invalid;
19255 }
19256
19257
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_start,f,true))
19258 {
19259 return qe_invalid;
19260 }
19261
19262
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_end,f,true))
19263 {
19264 return qe_invalid;
19265 }
19266
19267
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.loop,f,true))
19268 {
19269 return qe_invalid;
19270 }
19271
19272
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.volume,f,true))
19273 {
19274 return qe_invalid;
19275 }
19276
19277
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(Header->zelda_version < 0x193)
19278 {
19279 if(!p_igetl(&dummy,f,true))
19280 {
19281 return qe_invalid;
19282 }
19283 }
19284
19285
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version >= 3)
19286 {
19287
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19288 {
19289 return qe_invalid;
19290 }
19291 1530 }
19292
19293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(keepdata==true)
19294 {
19295 1629 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19296 1629 }
19297
19298
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19299 {
19300 // old format - a midi is a midi
19301
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19302 {
19303 return qe_invalid;
19304 }
19305
19306 //yes you can do this. Isn't the ? operator awesome? :)
19307
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19308 99 }
19309 else
19310 {
19311 // 'midi' could be midi or nes, gb, ... music
19312
2/4
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
1530 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19313 {
19314 return qe_invalid;
19315 }
19316
19317
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19318
19319
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 switch(temp.format)
19320 {
19321 case MFORMAT_MIDI:
19322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1530 times.
1530 if((ptr->data=read_midi(f, true))==NULL)
19323 {
19324 return qe_invalid;
19325 }
19326
19327 1530 break;
19328
19329 default:
19330 return qe_invalid;
19331 break;
19332 }
19333 }
19334 1629 }
19335 24948 }
19336
19337 99 return 0;
19338 99 }
19339
19340 99 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19341 {
19342 int32_t dummy;
19343 ZCHEATS tempzcheats;
19344 99 char temp_use_cheats=1;
19345 99 memset(&tempzcheats, 0, sizeof(tempzcheats));
19346 99 word s_version = 0;
19347
19348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
19349 {
19350 //section version info
19351
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
19352 {
19353 return qe_invalid;
19354 }
19355
19356 99 FFCore.quest_format[vCheats] = s_version;
19357 //al_trace("Cheats version %d\n", dummy);
19358
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
19359 {
19360 return qe_invalid;
19361 }
19362
19363 //section size
19364
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19365 {
19366 return qe_invalid;
19367 }
19368
19369 //finally... section data
19370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_getc(&temp_use_cheats,f,true))
19371 {
19372 return qe_invalid;
19373 }
19374 99 }
19375
19376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->data_flags[ZQ_CHEATS2])
19377 {
19378
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempzcheats.flags,f,true))
19379 {
19380 return qe_invalid;
19381 }
19382
19383
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19384 {
19385 return qe_invalid;
19386 }
19387 99 }
19388
19389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19390 {
19391 99 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19392 99 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19393 99 }
19394
19395 99 return 0;
19396 99 }
19397
19398 253 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19399 {
19400 int32_t dummy;
19401 253 word s_version=0, s_cversion=0;
19402 byte padding;
19403 word tempw;
19404
19405 253 zinitdata temp_zinit;
19406
19407 // Legacy item properties (now integrated into itemdata)
19408 byte sword_hearts[4];
19409 byte beam_hearts[4];
19410 253 byte beam_percent=0;
19411 word beam_power[4];
19412 253 byte hookshot_length=99;
19413 253 byte hookshot_links=100;
19414 253 byte longshot_length=99;
19415 253 byte longshot_links=100;
19416 253 byte moving_fairy_hearts=3;
19417 253 byte moving_fairy_heart_percent=0;
19418 253 byte stationary_fairy_hearts=3;
19419 253 byte stationary_fairy_heart_percent=0;
19420 253 byte moving_fairy_magic=0;
19421 253 byte moving_fairy_magic_percent=0;
19422 253 byte stationary_fairy_magic=0;
19423 253 byte stationary_fairy_magic_percent=0;
19424 253 byte blue_potion_hearts=100;
19425 253 byte blue_potion_heart_percent=1;
19426 253 byte red_potion_hearts=100;
19427 253 byte red_potion_heart_percent=1;
19428 253 byte blue_potion_magic=100;
19429 253 byte blue_potion_magic_percent=1;
19430 253 byte red_potion_magic=100;
19431 253 byte red_potion_magic_percent=1;
19432
19433
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 154 times.
253 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19434
19435
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
19436 {
19437 //section version info
19438
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
19439 {
19440 return qe_invalid;
19441 }
19442
19443 99 FFCore.quest_format[vInitData] = s_version;
19444
19445 //al_trace("Init data version %d\n", s_version);
19446
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
19447 {
19448 return qe_invalid;
19449 }
19450
19451 //section size
19452
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy,f,true))
19453 {
19454 return qe_invalid;
19455 }
19456 99 }
19457
19458 /* HIGHLY UNORTHODOX UPDATING THING, by L
19459 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19460 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19461 * changing from 13 to 14.
19462 */
19463
3/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 3 times.
99 if(keepdata && s_version < 14)
19464 3 fixpolsvoice=true;
19465
19466 /* End highly unorthodox updating thing */
19467
19468
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 23 times.
99 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19469 23 temp_zinit.jump_hero_layer_threshold=0;
19470
19471
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version >= 10)
19472 {
19473 char temp;
19474
19475 //new-style items
19476
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t j=0; j<256; j++)
19477 {
19478
2/4
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24576 times.
24576 if(!p_getc(&temp,f,true))
19479 return qe_invalid;
19480
19481 24576 temp_zinit.items[j] = (temp != 0);
19482 24576 }
19483 96 }
19484
19485
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 55 times.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19486 {
19487 char temp;
19488
19489 //finally... section data
19490
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 55 times.
154 if((Header->zelda_version > 0x192)||
19491 //new only
19492 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19493 {
19494 //OLD-style items... sigh
19495
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 10)
19496 {
19497
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19498 {
19499 return qe_invalid;
19500 }
19501
19502 3 temp_zinit.items[iRaft]=(temp != 0);
19503
19504
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19505 {
19506 return qe_invalid;
19507 }
19508
19509 3 temp_zinit.items[iLadder]=(temp != 0);
19510
19511
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19512 {
19513 return qe_invalid;
19514 }
19515
19516 3 temp_zinit.items[iBook]=(temp != 0);
19517
19518
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19519 {
19520 return qe_invalid;
19521 }
19522
19523 3 temp_zinit.items[iMKey]=(temp!=0);
19524
19525
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19526 {
19527 return qe_invalid;
19528 }
19529
19530 3 temp_zinit.items[iFlippers]=(temp != 0);
19531
19532
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19533 {
19534 return qe_invalid;
19535 }
19536
19537 3 temp_zinit.items[iBoots]=(temp!=0);
19538 3 }
19539 99 }
19540
19541
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 151 times.
154 if(s_version < 10)
19542 {
19543 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19544
19545
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempring,f,true))
19546 {
19547 return qe_invalid;
19548 }
19549
19550
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempsword,f,true))
19551 {
19552 return qe_invalid;
19553 }
19554
19555
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempshield,f,true))
19556 {
19557 return qe_invalid;
19558 }
19559
19560
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwallet,f,true))
19561 {
19562 return qe_invalid;
19563 }
19564
19565
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbracelet,f,true))
19566 {
19567 return qe_invalid;
19568 }
19569
19570
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempamulet,f,true))
19571 {
19572 return qe_invalid;
19573 }
19574
19575
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbow,f,true))
19576 {
19577 return qe_invalid;
19578 }
19579
19580 //old only
19581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19582 {
19583 tempring=(tempring)?(1<<(tempring-1)):0;
19584 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19585 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19586 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19587 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19588 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19589 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19590 }
19591
19592 //rings start at level 2... wtf
19593 //account for this -DD
19594 3 tempring <<= 1;
19595
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19596
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19597
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19598
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19599 //bracelet ALSO starts at level 2 :-( -DD
19600 3 tempbracelet<<=1;
19601
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19602
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19603
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19604
19605 //new only
19606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>173))
19607 {
19608 for(int32_t q=0; q<32; q++)
19609 {
19610 if(!p_getc(&padding,f,true))
19611 {
19612 return qe_invalid;
19613 }
19614 }
19615 }
19616
19617 char tempcandle, tempboomerang, temparrow, tempwhistle;
19618
19619
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempcandle,f,true))
19620 {
19621 return qe_invalid;
19622 }
19623
19624
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempboomerang,f,true))
19625 {
19626 return qe_invalid;
19627 }
19628
19629
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temparrow,f,true))
19630 {
19631 return qe_invalid;
19632 }
19633
19634
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19635 {
19636 return qe_invalid;
19637 }
19638
19639
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19640
19641
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwhistle,f,true))
19642 {
19643 return qe_invalid;
19644 }
19645
19646 //old only
19647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19648 {
19649 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19650 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19651 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19652 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19653 }
19654
19655
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19656
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19657
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19658
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19659 //What about the potion...?
19660
19661 3 }
19662
19663
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 77 times.
154 if(s_version < 29)
19664 {
19665 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19666 //to jab out my eye...
19667
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19668 return qe_invalid;
19669 77 temp_zinit.bombs = padding;
19670
19671
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19672 return qe_invalid;
19673 77 temp_zinit.super_bombs = padding;
19674 77 }
19675
19676 //Back to more OLD item code
19677
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
154 if(s_version < 10)
19678 {
19679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version > 0x192)||
19680 //new only
19681 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19682 {
19683
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19684 {
19685 return qe_invalid;
19686 }
19687
19688
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19689
19690
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19691 {
19692 return qe_invalid;
19693 }
19694
19695
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19696
19697
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19698 {
19699 return qe_invalid;
19700 }
19701
19702
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19703
19704
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19705 {
19706 return qe_invalid;
19707 }
19708
19709
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19710
19711
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19712 {
19713 return qe_invalid;
19714 }
19715
19716
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19717
19718
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19719 {
19720 return qe_invalid;
19721 }
19722
19723
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19724
19725
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19726 {
19727 return qe_invalid;
19728 }
19729
19730
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19731
19732
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19733 {
19734 return qe_invalid;
19735 }
19736
19737
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19738
19739
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19740 {
19741 return qe_invalid;
19742 }
19743
19744
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19745
19746
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19747 {
19748 return qe_invalid;
19749 }
19750
19751
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version == 0x192)
19752 {
19753 for(int32_t q=0; q<32; q++)
19754 {
19755 if(!p_getc(&padding,f,true))
19756 {
19757 return qe_invalid;
19758 }
19759 }
19760 }
19761 3 }
19762 3 }
19763
19764 //old only
19765
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<174))
19766 {
19767 byte equipment, items; //bit flags
19768
19769 if(!p_getc(&equipment,f,true))
19770 {
19771 return qe_invalid;
19772 }
19773
19774 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19775 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19776 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19777 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19778 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19779 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19780
19781
19782 if(!p_getc(&items,f,true))
19783 {
19784 return qe_invalid;
19785 }
19786
19787 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19788 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19789 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19790 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19791 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19792 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19793 }
19794
19795 if(!p_getc(&temp_zinit.hc,f,true))
19796 {
19797 return qe_invalid;
19798 }
19799
19800
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
19801 {
19802 byte temphp;
19803
19804
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
19805 {
19806 return qe_invalid;
19807 }
19808
19809 3 temp_zinit.start_heart=temphp;
19810
19811
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
19812 {
19813 return qe_invalid;
19814 }
19815
19816 3 temp_zinit.cont_heart=temphp;
19817 3 }
19818 else
19819 {
19820
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_heart,f,true))
19821 {
19822 return qe_invalid;
19823 }
19824
19825
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.cont_heart,f,true))
19826 {
19827 return qe_invalid;
19828 }
19829 }
19830
19831
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.hcp,f,true))
19832 {
19833 return qe_invalid;
19834 }
19835
19836
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version >= 14)
19837 {
19838
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
19839 {
19840 return qe_invalid;
19841 }
19842
19843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version<16) // July 2007
19844 {
19845 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
19846 temp_zinit.hcp_per_hc = 0xFF;
19847
19848 //Dispose of legacy rule
19849 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
19850 }
19851 96 }
19852
19853
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 29)
19854 {
19855
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19856 return qe_invalid;
19857 77 temp_zinit.max_bombs = padding;
19858 77 }
19859
19860
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.keys,f,true))
19861 {
19862 return qe_invalid;
19863 }
19864
19865
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.rupies,f,true))
19866 {
19867 return qe_invalid;
19868 }
19869
19870
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.triforce,f,true))
19871 {
19872 return qe_invalid;
19873 }
19874
19875
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19876 {
19877
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
19878 {
19879
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.map[i],f,true))
19880 {
19881 return qe_invalid;
19882 }
19883 6144 }
19884
19885
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
19886 {
19887
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.compass[i],f,true))
19888 {
19889 return qe_invalid;
19890 }
19891 6144 }
19892 96 }
19893 else
19894 {
19895
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
19896 {
19897
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.map[i],f,true))
19898 {
19899 return qe_invalid;
19900 }
19901 96 }
19902
19903
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
19904 {
19905
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.compass[i],f,true))
19906 {
19907 return qe_invalid;
19908 }
19909 96 }
19910 }
19911
19912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version > 0x192)||
19913 //new only
19914 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19915 {
19916
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19917 {
19918
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
19919 {
19920
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.boss_key[i],f,true))
19921 {
19922 return qe_invalid;
19923 }
19924 6144 }
19925 96 }
19926 else
19927 {
19928
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
19929 {
19930
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.boss_key[i],f,true))
19931 {
19932 return qe_invalid;
19933 }
19934 96 }
19935 }
19936 99 }
19937
19938
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1584 times.
1683 for(int32_t i=0; i<16; i++)
19939 {
19940
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
1584 if(!p_getc(&temp_zinit.misc[i],f,true))
19941 {
19942 return qe_invalid;
19943 }
19944 1584 }
19945
19946
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 3 times.
111 if(s_version < 15) for(int32_t i=0; i<4; i++)
19947 {
19948
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&sword_hearts[i],f,true))
19949 {
19950 return qe_invalid;
19951 }
19952 15 }
19953
19954
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_map,f,true))
19955 {
19956 return qe_invalid;
19957 }
19958
19959
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_screen,f,true))
19960 {
19961 return qe_invalid;
19962 }
19963
19964
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
19965 {
19966 byte tempmp;
19967
19968
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
19969 {
19970 return qe_invalid;
19971 }
19972
19973 3 temp_zinit.max_magic=tempmp;
19974
19975
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
19976 {
19977 return qe_invalid;
19978 }
19979
19980 3 temp_zinit.magic=tempmp;
19981 3 }
19982 else
19983 {
19984
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_magic,f,true))
19985 {
19986 return qe_invalid;
19987 }
19988
19989
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.magic,f,true))
19990 {
19991 return qe_invalid;
19992 }
19993 }
19994
19995
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
19996 {
19997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version < 12)
19998 {
19999 3 temp_zinit.max_magic*=32;
20000 3 temp_zinit.magic*=32;
20001 3 }
20002
20003
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20004 {
20005
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_hearts[i],f,true))
20006 {
20007 return qe_invalid;
20008 }
20009 12 }
20010
20011
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&beam_percent,f,true))
20012 {
20013 return qe_invalid;
20014 }
20015 3 }
20016 else
20017 {
20018
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20019 {
20020 return qe_invalid;
20021 }
20022 }
20023
20024
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20025 {
20026 byte tempbp;
20027
20028
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20029 {
20030
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20031 {
20032 return qe_invalid;
20033 }
20034
20035 12 beam_power[i]=tempbp;
20036 12 }
20037
20038
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&hookshot_links,f,true))
20039 {
20040 return qe_invalid;
20041 }
20042
20043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version>6)
20044 {
20045 if(!p_getc(&hookshot_length,f,true))
20046 {
20047 return qe_invalid;
20048 }
20049
20050 if(!p_getc(&longshot_links,f,true))
20051 {
20052 return qe_invalid;
20053 }
20054
20055 if(!p_getc(&longshot_length,f,true))
20056 {
20057 return qe_invalid;
20058 }
20059 }
20060 3 }
20061
20062
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20063 {
20064 return qe_invalid;
20065 }
20066
20067
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20068 {
20069 return qe_invalid;
20070 }
20071
20072
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.subscreen,f,true))
20073 {
20074 return qe_invalid;
20075 }
20076
20077 //old only
20078
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20079 {
20080 for(int32_t i=0; i<32; i++)
20081 {
20082 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20083 {
20084 return qe_invalid;
20085 }
20086 }
20087 }
20088
20089
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20090 {
20091
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version <= 10)
20092 {
20093 byte tempbyte;
20094
20095
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbyte,f,true))
20096 {
20097 return qe_invalid;
20098 }
20099
20100 3 temp_zinit.start_dmap = (word)tempbyte;
20101 3 }
20102 else
20103 {
20104
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20105 {
20106 return qe_invalid;
20107 }
20108 }
20109
20110
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20111 {
20112 return qe_invalid;
20113 }
20114 99 }
20115
20116
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
99 if(s_version>1 && s_version < 29)
20117 {
20118
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20119 return qe_invalid;
20120 74 temp_zinit.arrows = padding;
20121
20122
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20123 return qe_invalid;
20124 74 temp_zinit.max_arrows = padding;
20125 74 }
20126
20127
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version>2)
20128 {
20129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version <= 10)
20130 {
20131 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20132 {
20133 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20134 {
20135 return qe_invalid;
20136 }
20137 }
20138 }
20139 else
20140 {
20141
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXLEVELS; i++)
20142 {
20143
2/4
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49152 times.
✗ Branch 3 not taken.
49152 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20144 {
20145 return qe_invalid;
20146 }
20147 49152 }
20148 }
20149 96 }
20150
20151
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>3)
20152 {
20153
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20154 {
20155 return qe_invalid;
20156 }
20157
20158
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20159 {
20160 return qe_invalid;
20161 }
20162
20163
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20164 {
20165 return qe_invalid;
20166 }
20167
20168
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20169 {
20170 return qe_invalid;
20171 }
20172
20173
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20174 {
20175 return qe_invalid;
20176 }
20177
20178
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20179 {
20180 return qe_invalid;
20181 }
20182
20183
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20184 {
20185 return qe_invalid;
20186 }
20187
20188
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20189 {
20190 return qe_invalid;
20191 }
20192
20193
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20194
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20195 96 }
20196
20197
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>4 && s_version<15)
20198 {
20199 if(!p_getc(&moving_fairy_hearts,f,true))
20200 {
20201 return qe_invalid;
20202 }
20203
20204 if(!p_getc(&moving_fairy_heart_percent,f,true))
20205 {
20206 return qe_invalid;
20207 }
20208 }
20209
20210
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>5 && s_version < 10)
20211 {
20212 if(!p_getc(&temp,f,true))
20213 {
20214 return qe_invalid;
20215 }
20216
20217 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20218 }
20219
20220
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>6 && s_version<15)
20221 {
20222 if(!p_getc(&stationary_fairy_hearts,f,true))
20223 {
20224 return qe_invalid;
20225 }
20226
20227 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20228 {
20229 return qe_invalid;
20230 }
20231
20232 if(!p_getc(&moving_fairy_magic,f,true))
20233 {
20234 return qe_invalid;
20235 }
20236
20237 if(!p_getc(&moving_fairy_magic_percent,f,true))
20238 {
20239 return qe_invalid;
20240 }
20241
20242 if(!p_getc(&stationary_fairy_magic,f,true))
20243 {
20244 return qe_invalid;
20245 }
20246
20247 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20248 {
20249 return qe_invalid;
20250 }
20251
20252 if(!p_getc(&blue_potion_hearts,f,true))
20253 {
20254 return qe_invalid;
20255 }
20256
20257 if(!p_getc(&blue_potion_heart_percent,f,true))
20258 {
20259 return qe_invalid;
20260 }
20261
20262 if(!p_getc(&red_potion_hearts,f,true))
20263 {
20264 return qe_invalid;
20265 }
20266
20267 if(!p_getc(&red_potion_heart_percent,f,true))
20268 {
20269 return qe_invalid;
20270 }
20271
20272 if(!p_getc(&blue_potion_magic,f,true))
20273 {
20274 return qe_invalid;
20275 }
20276
20277 if(!p_getc(&blue_potion_magic_percent,f,true))
20278 {
20279 return qe_invalid;
20280 }
20281
20282 if(!p_getc(&red_potion_magic,f,true))
20283 {
20284 return qe_invalid;
20285 }
20286
20287 if(!p_getc(&red_potion_magic_percent,f,true))
20288 {
20289 return qe_invalid;
20290 }
20291 }
20292
20293
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>6)
20294 {
20295
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20296 {
20297 return qe_invalid;
20298 }
20299 96 }
20300
20301
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>7)
20302 {
20303
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20304 {
20305 return qe_invalid;
20306 }
20307 96 }
20308
20309
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>8)
20310 {
20311
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20312 {
20313 return qe_invalid;
20314 }
20315
20316
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_keys,f,true))
20317 {
20318 return qe_invalid;
20319 }
20320 96 }
20321
20322
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>16)
20323 {
20324
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.gravity,f,true))
20325 {
20326 return qe_invalid;
20327 }
20328
20329
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.terminalv,f,true))
20330 {
20331 return qe_invalid;
20332 }
20333
20334
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_speed,f,true))
20335 {
20336 return qe_invalid;
20337 }
20338
20339
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.transition_type,f,true))
20340 {
20341 return qe_invalid;
20342 }
20343
20344
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20345 {
20346 return qe_invalid;
20347 }
20348 96 }
20349
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
3 else if(replay_is_replaying() && replay_get_version() < 13)
20350 3 temp_zinit.msg_speed = 0;
20351
20352
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>17)
20353 {
20354
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20355 {
20356 return qe_invalid;
20357 }
20358 96 }
20359
20360 //expaned init data for larger values in 2.55
20361
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20362 {
20363
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.bombs,f,true))
20364 {
20365 return qe_invalid;
20366 }
20367
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20368 {
20369 return qe_invalid;
20370 }
20371
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20372 {
20373 return qe_invalid;
20374 }
20375
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20376 {
20377 return qe_invalid;
20378 }
20379
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.arrows,f,true))
20380 {
20381 return qe_invalid;
20382 }
20383
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20384 {
20385 return qe_invalid;
20386 }
20387
20388 22 }
20389
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 20 )
20390 {
20391
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroStep,f,true))
20392 {
20393 return qe_invalid;
20394 }
20395 22 }
20396 else
20397 {
20398 77 temp_zinit.heroStep = 150; //1.5 pixels per frame
20399 }
20400
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 21 )
20401 {
20402
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20403 {
20404 return qe_invalid;
20405 }
20406 22 }
20407 else
20408 {
20409 77 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20410 }
20411 //old only
20412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20413 {
20414 byte items2;
20415
20416 if(!p_getc(&items2,f,true))
20417 {
20418 return qe_invalid;
20419 }
20420
20421 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20422 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20423 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20424 }
20425
20426
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
20427 {
20428 for(int32_t q=0; q<96; q++)
20429 {
20430 if(!p_getc(&padding,f,true))
20431 {
20432 return qe_invalid;
20433 }
20434 }
20435
20436 //new only
20437 if((Header->zelda_version == 0x192)&&(Header->build>173))
20438 {
20439 if(!p_getc(&padding,f,true))
20440 {
20441 return qe_invalid;
20442 }
20443
20444 if(!p_getc(&padding,f,true))
20445 {
20446 return qe_invalid;
20447 }
20448 }
20449 }
20450 99 }
20451
20452
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
154 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20453 {
20454 //temp_zinit.shield=i_smallshield;
20455
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20456
20457
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(sshieldid != -1)
20458 3 temp_zinit.items[sshieldid] = true;
20459 3 }
20460
20461
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20462 {
20463 temp_zinit.hc=3;
20464 temp_zinit.start_heart=3;
20465 temp_zinit.cont_heart=3;
20466 temp_zinit.max_bombs=8;
20467 }
20468
20469
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20470 {
20471 sword_hearts[0]=0;
20472 sword_hearts[1]=5;
20473 sword_hearts[2]=12;
20474 sword_hearts[3]=21;
20475 }
20476
20477
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20478 {
20479 temp_zinit.last_map=0;
20480 temp_zinit.last_screen=0;
20481 }
20482
20483
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20484 {
20485 temp_zinit.max_magic=0;
20486 temp_zinit.magic=0;
20487 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20488 }
20489
20490
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20491 {
20492
20493 for(int32_t x=0; x<4; x++)
20494 {
20495 beam_hearts[x]=100;
20496 }
20497
20498 for(int32_t i=0; i<idBP_MAX; i++)
20499 {
20500 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20501 set_bit(quest_rules,qr_LENSHINTS+i,0);
20502 }
20503
20504 for(int32_t x=0; x<4; x++)
20505 {
20506 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20507 }
20508
20509 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20510 hookshot_links=100;
20511 temp_zinit.msg_more_x=224;
20512 temp_zinit.msg_more_y=64;
20513 }
20514
20515 // Okay, let's put these legacy values into itemsbuf.
20516
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20517
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 768 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
20518 {
20519
11/11
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 738 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
768 switch(i)
20520 {
20521 case iFairyStill:
20522 3 itemsbuf[i].misc1 = stationary_fairy_hearts;
20523 3 itemsbuf[i].misc2 = stationary_fairy_magic;
20524 3 itemsbuf[i].misc3 = 0;
20525 3 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20526 3 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20527 3 break;
20528
20529 case iFairyMoving:
20530 3 itemsbuf[i].misc1 = moving_fairy_hearts;
20531 3 itemsbuf[i].misc2 = moving_fairy_magic;
20532 3 itemsbuf[i].misc3 = 50;
20533 3 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20534 3 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20535 3 break;
20536
20537 case iRPotion:
20538 3 itemsbuf[i].misc1 = red_potion_hearts;
20539 3 itemsbuf[i].misc2 = red_potion_magic;
20540 3 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20541 3 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20542 3 break;
20543
20544 case iBPotion:
20545 3 itemsbuf[i].misc1 = blue_potion_hearts;
20546 3 itemsbuf[i].misc2 = blue_potion_magic;
20547 3 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20548 3 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20549 3 break;
20550
20551 case iSword:
20552 3 itemsbuf[i].pickup_hearts = sword_hearts[0];
20553 3 itemsbuf[i].misc1 = beam_hearts[0];
20554 3 itemsbuf[i].misc2 = beam_power[0];
20555 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20556
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20557 3 break;
20558
20559 case iWSword:
20560 3 itemsbuf[i].pickup_hearts = sword_hearts[1];
20561 3 itemsbuf[i].misc1 = beam_hearts[1];
20562 3 itemsbuf[i].misc2 = beam_power[1];
20563
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20564 3 break;
20565
20566 case iMSword:
20567 3 itemsbuf[i].pickup_hearts = sword_hearts[2];
20568 3 itemsbuf[i].misc1 = beam_hearts[2];
20569 3 itemsbuf[i].misc2 = beam_power[2];
20570
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20571 3 break;
20572
20573 case iXSword:
20574 3 itemsbuf[i].pickup_hearts = sword_hearts[3];
20575 3 itemsbuf[i].misc1 = beam_hearts[3];
20576 3 itemsbuf[i].misc2 = beam_power[3];
20577
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20578 3 break;
20579
20580 case iHookshot:
20581 3 itemsbuf[i].misc1 = hookshot_length;
20582 3 itemsbuf[i].misc2 = hookshot_links;
20583 3 break;
20584
20585 case iLongshot:
20586 3 itemsbuf[i].misc1 = longshot_length;
20587 3 itemsbuf[i].misc2 = longshot_links;
20588 3 break;
20589 }
20590 771 }
20591
20592
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20593 {
20594 //was new subscreen rule
20595 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20596 set_bit(quest_rules,qr_FREEFORM,0);
20597 }
20598
20599
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20600 {
20601 temp_zinit.start_dmap=0;
20602 }
20603
20604
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20605 {
20606 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20607 }
20608
20609
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
99 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20610 {
20611 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20612 temp_zinit.max_rupees=999;
20613 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20614 }
20615
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20616 {
20617 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20618 temp_zinit.max_bombs = 8;
20619 }
20620 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20621 //time to ensure that we port all new values properly:
20622
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version < 0x250)
20623 {
20624
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20625 3 }
20626
20627
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 21)
20628 {
20629
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20630 {
20631 return qe_invalid;
20632 }
20633
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20634 {
20635 return qe_invalid;
20636 }
20637
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20638 {
20639 return qe_invalid;
20640 }
20641
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20642 {
20643 return qe_invalid;
20644 }
20645 22 }
20646 else
20647 {
20648 77 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20649 77 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20650 77 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20651 77 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20652 }
20653
20654
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 22)
20655 {
20656
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20657 {
20658
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20659 {
20660 return qe_invalid;
20661 }
20662 550 }
20663
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20664 {
20665
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20666 {
20667 return qe_invalid;
20668 }
20669 550 }
20670 22 }
20671 else
20672 {
20673
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 77 times.
2002 for(int32_t q = 0; q < 25; ++q)
20674 {
20675 1925 temp_zinit.scrcnt[q] = 0;
20676 1925 temp_zinit.scrmaxcnt[q] = 0;
20677 1925 }
20678 }
20679
20680
20681
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 23)
20682 {
20683
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_type,f,true))
20684 {
20685 return qe_invalid;
20686 }
20687
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_arg,f,true))
20688 {
20689 return qe_invalid;
20690 }
20691
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_percent,f,true))
20692 {
20693 return qe_invalid;
20694 }
20695
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20696 {
20697 return qe_invalid;
20698 }
20699
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20700 {
20701 return qe_invalid;
20702 }
20703 22 }
20704 else
20705 {
20706 77 temp_zinit.dither_type = 0;
20707 77 temp_zinit.dither_arg = 0;
20708 77 temp_zinit.dither_percent = 20;
20709 77 temp_zinit.def_lightrad = 24;
20710 77 temp_zinit.transdark_percent = 0;
20711 }
20712
20713
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 24)
20714 {
20715
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.darkcol,f,true))
20716 {
20717 return qe_invalid;
20718 }
20719 22 }
20720 else
20721 {
20722 77 temp_zinit.darkcol = BLACK;
20723 }
20724
20725
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 25)
20726 {
20727
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.gravity2,f,true))
20728 {
20729 return qe_invalid;
20730 }
20731
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20732 {
20733 return qe_invalid;
20734 }
20735 22 }
20736 else
20737 {
20738 77 temp_zinit.gravity2 = temp_zinit.gravity*100;
20739 77 temp_zinit.swimgravity = 5;
20740 }
20741
20742
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 26)
20743 {
20744
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20745 {
20746 return qe_invalid;
20747 }
20748
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20749 {
20750 return qe_invalid;
20751 }
20752
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20753 {
20754 return qe_invalid;
20755 }
20756 22 }
20757 else
20758 {
20759 77 temp_zinit.heroSideswimUpStep = 150;
20760 77 temp_zinit.heroSideswimSideStep = 100;
20761 77 temp_zinit.heroSideswimDownStep = 75;
20762 }
20763
20764
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 27)
20765 {
20766
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20767 {
20768 return qe_invalid;
20769 }
20770 22 }
20771 else
20772 {
20773 77 temp_zinit.exitWaterJump = 0;
20774 }
20775
20776
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 29)
20777 {
20778
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20779 {
20780 return qe_invalid;
20781 }
20782 22 }
20783 else
20784 {
20785 77 temp_zinit.bunny_ltm = 0;
20786 }
20787
20788
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 30)
20789 {
20790
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20791 {
20792 return qe_invalid;
20793 }
20794 22 }
20795 else
20796 {
20797 77 temp_zinit.switchhookstyle = 1;
20798 }
20799
20800
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 31)
20801 {
20802
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20803 {
20804 return qe_invalid;
20805 }
20806 22 }
20807 else
20808 {
20809
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20810
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20811 }
20812
20813
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.clear_genscript();
20814
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(s_version > 32)
20815 {
20816 13 word numgenscript = 0;
20817
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&numgenscript,f,true))
20818 return qe_invalid;
20819
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 for(auto q = 1; q < numgenscript; ++q)
20820 {
20821
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
20822 return qe_invalid;
20823
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
20824 continue;
20825 1 temp_zinit.gen_doscript[q] = padding&1;
20826
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
20827 return qe_invalid;
20828
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
20829 return qe_invalid;
20830
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
20831
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
20832 return qe_invalid;
20833
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
20834 return qe_invalid;
20835
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
20836 return qe_invalid;
20837
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
20838 return qe_invalid;
20839 1 }
20840 13 }
20841
20842
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata==true)
20843 {
20844
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 zinit = temp_zinit;
20845
20846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(zinit.heroAnimationStyle==las_zelda3slow)
20847 {
20848 hero_animation_speed=2;
20849 }
20850 else
20851 {
20852 99 hero_animation_speed=1;
20853 }
20854 99 }
20855
20856 99 return 0;
20857 407 }
20858
20859 /*
20860 void setupitemdropsets()
20861 {
20862 for(int32_t i=0; i<isMAX; i++)
20863 {
20864 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20865 }
20866 }
20867 */
20868
20869 96 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
20870 {
20871 96 build=build; // here to prevent compiler warnings
20872 dword dummy_dword;
20873 96 word item_drop_sets_to_read=0;
20874 item_drop_object tempitemdrop;
20875 96 word s_version=0, s_cversion=0;
20876
20877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
20878 {
20879
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20880 {
20881 24576 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20882 24576 }
20883 96 }
20884
20885
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(version > 0x192)
20886 {
20887 96 item_drop_sets_to_read=0;
20888
20889 //section version info
20890
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_version,f,true))
20891 {
20892 return qe_invalid;
20893 }
20894
20895 96 FFCore.quest_format[vItemDropsets] = s_version;
20896
20897 //al_trace("Item drop sets version %d\n", s_version);
20898
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
20899 {
20900 return qe_invalid;
20901 }
20902
20903 //section size
20904
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
20905 {
20906 return qe_invalid;
20907 }
20908
20909 //finally... section data
20910
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&item_drop_sets_to_read,f,true))
20911 {
20912 return qe_invalid;
20913 }
20914 96 }
20915 else
20916 {
20917 if(keepdata==true)
20918 {
20919 init_item_drop_sets();
20920 }
20921 }
20922
20923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version>=1)
20924 {
20925
2/2
✓ Branch 0 taken 1844 times.
✓ Branch 1 taken 96 times.
1940 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20926 {
20927
1/2
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
1844 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
20928 {
20929 return qe_invalid;
20930 }
20931
20932
2/2
✓ Branch 0 taken 18440 times.
✓ Branch 1 taken 1844 times.
20284 for(int32_t j=0; j<10; ++j)
20933 {
20934
1/2
✓ Branch 0 taken 18440 times.
✗ Branch 1 not taken.
18440 if(!p_igetw(&tempitemdrop.item[j],f,true))
20935 {
20936 return qe_invalid;
20937 }
20938 18440 }
20939
20940
2/2
✓ Branch 0 taken 20284 times.
✓ Branch 1 taken 1844 times.
22128 for(int32_t j=0; j<11; ++j)
20941 {
20942
1/2
✓ Branch 0 taken 20284 times.
✗ Branch 1 not taken.
20284 if(!p_igetw(&tempitemdrop.chance[j],f,true))
20943 {
20944 return qe_invalid;
20945 }
20946 20284 }
20947
20948 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20949 // overrides the quest's set #12.
20950
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2 && i==12)
20951 continue;
20952
20953 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20954
1/4
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2) for(int32_t j=0; j<10; ++j)
20955 {
20956 int32_t it = tempitemdrop.item[j];
20957
20958 if((itemsbuf[it].family == itype_rupee
20959 && ((itemsbuf[it].amount)&0xFFF) == 10)
20960 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20961 {
20962 tempitemdrop.chance[j+1]=0;
20963 }
20964 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20965 {
20966 tempitemdrop.chance[j+1]=0;
20967 }
20968
20969 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20970 if(itemsbuf[it].family == itype_misc)
20971 {
20972 // If a non-gameplay item was selected, then item drop was aborted.
20973 // Reflect this by increasing the 'Nothing' chance accordingly.
20974 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20975 tempitemdrop.chance[j+1]=0;
20976 }
20977 }
20978
20979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
1844 if(keepdata)
20980 {
20981 1844 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20982 1844 }
20983 1844 }
20984 96 }
20985
20986 96 return 0;
20987 96 }
20988
20989 96 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
20990 {
20991 int32_t temp_num;
20992 dword dummy_dword;
20993 word num_favorite_combos;
20994 word num_favorite_combo_aliases;
20995 96 word s_version=0, s_cversion=0;
20996
20997 //section version info
20998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
20999 {
21000 return qe_invalid;
21001 }
21002
21003 96 FFCore.quest_format[vFavourites] = s_version;
21004
21005
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
21006 {
21007 return qe_invalid;
21008 }
21009
21010 //section size
21011
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
21012 {
21013 return qe_invalid;
21014 }
21015
21016 //finally... section data
21017
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combos,f,true))
21018 {
21019 return qe_invalid;
21020 }
21021
21022
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combos; i++)
21023 {
21024
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 if(!p_igetl(&temp_num,f,true))
21025 {
21026 return qe_invalid;
21027 }
21028
21029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21030 {
21031 9600 favorite_combos[i]=temp_num;
21032 9600 }
21033 9600 }
21034
21035
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21036 {
21037 return qe_invalid;
21038 }
21039
21040
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21041 {
21042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(!p_igetl(&temp_num,f,true))
21043 {
21044 return qe_invalid;
21045 }
21046
21047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21048 {
21049 9600 favorite_comboaliases[i]=temp_num;
21050 9600 }
21051 9600 }
21052
21053 96 return 0;
21054 96 }
21055
21056 /*
21057 switch (ret) {
21058 case 0:
21059 break;
21060
21061 case qe_invalid:
21062 goto invalid;
21063 break;
21064 default:
21065 pack_fclose(f);
21066 if(!oldquest)
21067 delete_file(tmpfilename);
21068 return ret;
21069 break;
21070 }
21071 */
21072
21073 const char *skip_text[skip_max]=
21074 {
21075 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21076 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21077 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21078 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21079 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21080 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21081 "skip_favorites"
21082 };
21083
21084
21085 void port250QuestRules(){
21086
21087 portCandleRules(); //Candle
21088 portBombRules();
21089
21090 }
21091
21092 void portCandleRules()
21093 {
21094 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21095 //itemdata itemsbuf;
21096 for ( int32_t q = 0; q < MAXITEMS; q++ )
21097 {
21098 if ( itemsbuf[q].family == itype_candle )
21099 {
21100 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21101 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21102 }
21103 }
21104 }
21105
21106 void portBombRules()
21107 {
21108 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21109 //itemdata itemsbuf;
21110 for ( int32_t q = 0; q < MAXITEMS; q++ )
21111 {
21112 if ( itemsbuf[q].family == itype_bomb )
21113 {
21114 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21115 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21116 }
21117 }
21118
21119 }
21120
21121 //Internal function for loadquest wrapper
21122 99 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21123 {
21124 99 DMapEditorLastMaptileUsed = 0;
21125 99 combosread=false;
21126 99 mapsread=false;
21127 99 fixffcs=false;
21128
21129
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21130 {
21131 keepall=false;
21132 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21133 }
21134
21135 // show_progress=true;
21136 char tmpfilename[L_tmpnam];
21137 99 temp_name(tmpfilename);
21138 // char percent_done[30];
21139 99 bool catchup=false;
21140 byte tempbyte;
21141 99 word old_map_count=map_count;
21142
21143 99 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21144 99 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21145 99 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21146
21147
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_rules))
21148 {
21149 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21150 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21151 }
21152
21153 99 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21154 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21155
21156
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_midis))
21157 {
21158 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21159 }
21160
21161
21162
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21163 {
21164 99 zScript.clear();
21165 99 globalmap.clear();
21166 99 genericmap.clear();
21167 99 ffcmap.clear();
21168 99 itemmap.clear();
21169 99 npcmap.clear();
21170 99 ewpnmap.clear();
21171 99 lwpnmap.clear();
21172 99 playermap.clear();
21173 99 dmapmap.clear();
21174 99 screenmap.clear();
21175 99 itemspritemap.clear();
21176 99 comboscriptmap.clear();
21177
21178
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21179 {
21180 50589 ffcmap[i].clear();
21181 50589 }
21182
21183 99 globalmap[0].slotname = "Slot 1:";
21184 99 globalmap[0].scriptname = "~Init";
21185 99 globalmap[0].update();
21186
21187
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 99 times.
792 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21188 {
21189 693 globalmap[i].clear();
21190 693 }
21191
21192
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21193 {
21194 25245 itemmap[i].clear();
21195 25245 }
21196
21197 //new script types -- prevent carrying over to a quest that you load after reading them
21198 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21199
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21200 {
21201 25245 npcmap[i].clear();
21202 25245 }
21203
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21204 {
21205 25245 lwpnmap[i].clear();
21206 25245 }
21207
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21208 {
21209 25245 ewpnmap[i].clear();
21210 25245 }
21211
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 99 times.
495 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21212 {
21213 396 playermap[i].clear();
21214 396 }
21215
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21216 {
21217 25245 dmapmap[i].clear();
21218 25245 }
21219
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21220 {
21221 25245 screenmap[i].clear();
21222 25245 }
21223
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21224 {
21225 25245 itemspritemap[i].clear();
21226 25245 }
21227
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21228 {
21229 50589 comboscriptmap[i].clear();
21230 50589 }
21231
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21232 {
21233 50589 genericmap[i].clear();
21234 50589 }
21235
21236 99 reset_scripts();
21237 99 }
21238
21239 zquestheader tempheader;
21240 99 memset(&tempheader, 0, sizeof(zquestheader));
21241 99 zinfo tempzi;
21242 99 tempzi.clear();
21243 99 load_tmp_zi = &tempzi;
21244
21245 // oldquest flag is set when an unencrypted qst file is suspected.
21246 99 bool oldquest = false;
21247 99 int32_t open_error=0;
21248 char deletefilename[1024];
21249 99 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21250
21251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!f)
21252 return open_error;
21253 char zinfofilename[2048];
21254 99 replace_extension(zinfofilename, filename, "zinfo", 2047);
21255 99 int32_t ret=0;
21256
21257 //header
21258 99 box_out("Reading Header...");
21259 99 ret=readheader(f, &tempheader, true, printmetadata);
21260
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21261 99 box_out("okay.");
21262 99 box_eol();
21263
21264
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(read_zinfo)
21265 {
21266 22 box_out("Reading ZInfo - ");
21267
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 box_out(read_ext_zinfo ? "External..." : "Internal...");
21268
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 if(read_ext_zinfo)
21269 {
21270 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21271 1 ret=readzinfo(inf, tempzi, tempheader);
21272
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21273
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21274 1 }
21275 else
21276 {
21277 21 ret=readzinfo(f, tempzi, tempheader);
21278
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
21 checkstatus(ret);
21279 }
21280 22 box_out("okay.");
21281 22 box_eol();
21282 22 }
21283
21284
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version>=0x193)
21285 {
21286 dword section_id;
21287
21288 //section id
21289
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_mgetl(&section_id,f,true))
21290 {
21291 return qe_invalid;
21292 }
21293
21294
2/2
✓ Branch 0 taken 2349 times.
✓ Branch 1 taken 99 times.
2448 while(!pack_feof(f))
21295 {
21296
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 99 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 96 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 99 times.
✓ Branch 10 taken 99 times.
✓ Branch 11 taken 99 times.
✓ Branch 12 taken 99 times.
✓ Branch 13 taken 96 times.
✓ Branch 14 taken 96 times.
✓ Branch 15 taken 99 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 96 times.
✓ Branch 18 taken 96 times.
✓ Branch 19 taken 96 times.
✓ Branch 20 taken 96 times.
✓ Branch 21 taken 99 times.
✓ Branch 22 taken 99 times.
✓ Branch 23 taken 96 times.
✓ Branch 24 taken 96 times.
2349 switch(section_id)
21297 {
21298 case ID_RULES:
21299
21300 //rules
21301
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21302 {
21303 box_out("found.");
21304 box_eol();
21305 catchup=false;
21306 }
21307
21308 99 box_out("Reading Rules...");
21309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21310
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21311 99 box_out("okay.");
21312 99 box_eol();
21313 99 break;
21314
21315 case ID_STRINGS:
21316
21317 //strings
21318
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21319 {
21320 box_out("found.");
21321 box_eol();
21322 catchup=false;
21323 }
21324
21325 99 box_out("Reading Strings...");
21326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21327
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21328 99 box_out("okay.");
21329 99 box_eol();
21330 99 break;
21331
21332 case ID_MISC:
21333
21334 //misc data
21335
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21336 {
21337 box_out("found.");
21338 box_eol();
21339 catchup=false;
21340 }
21341
21342 99 box_out("Reading Misc. Data...");
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21344
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21345 99 box_out("okay.");
21346 99 box_eol();
21347 99 break;
21348
21349 case ID_TILES:
21350
21351 //tiles
21352
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21353 {
21354 box_out("found.");
21355 box_eol();
21356 catchup=false;
21357 }
21358
21359 99 box_out("Reading Tiles...");
21360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21361
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21362 99 box_out("okay.");
21363 99 box_eol();
21364 99 break;
21365
21366 case ID_COMBOS:
21367
21368 //combos
21369
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21370 {
21371 box_out("found.");
21372 box_eol();
21373 catchup=false;
21374 }
21375
21376 99 box_out("Reading Combos...");
21377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21378 99 combosread=true;
21379
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21380 99 box_out("okay.");
21381 99 box_eol();
21382 99 break;
21383
21384 case ID_COMBOALIASES:
21385
21386 //combo aliases
21387
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21388 {
21389 box_out("found.");
21390 box_eol();
21391 catchup=false;
21392 }
21393
21394 96 box_out("Reading Combo Aliases...");
21395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21396
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21397 96 box_out("okay.");
21398 96 box_eol();
21399 96 break;
21400
21401 case ID_CSETS:
21402
21403 //color data
21404
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21405 {
21406 box_out("found.");
21407 box_eol();
21408 catchup=false;
21409 }
21410
21411 99 box_out("Reading Color Data...");
21412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21413
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21414 99 box_out("okay.");
21415 99 box_eol();
21416 99 break;
21417
21418 case ID_MAPS:
21419
21420 //maps
21421
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21422 {
21423 box_out("found.");
21424 box_eol();
21425 catchup=false;
21426 }
21427
21428 99 box_out("Reading Maps...");
21429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21430 99 mapsread=true;
21431
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21432 99 box_out("okay.");
21433 99 box_eol();
21434 99 break;
21435
21436 case ID_DMAPS:
21437
21438 //dmaps
21439
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21440 {
21441 box_out("found.");
21442 box_eol();
21443 catchup=false;
21444 }
21445
21446 99 box_out("Reading DMaps...");
21447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21448
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21449 99 box_out("okay.");
21450 99 box_eol();
21451 99 break;
21452
21453 case ID_DOORS:
21454
21455 //door combo sets
21456
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21457 {
21458 box_out("found.");
21459 box_eol();
21460 catchup=false;
21461 }
21462
21463 99 box_out("Reading Doors...");
21464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21465
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21466 99 box_out("okay.");
21467 99 box_eol();
21468 99 break;
21469
21470 case ID_ITEMS:
21471
21472 //items
21473
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21474 {
21475 box_out("found.");
21476 box_eol();
21477 catchup=false;
21478 }
21479
21480 99 box_out("Reading Items...");
21481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21482
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21483
21484 99 box_out("okay.");
21485 99 box_eol();
21486 99 break;
21487
21488 case ID_WEAPONS:
21489
21490 //weapons
21491
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21492 {
21493 box_out("found.");
21494 box_eol();
21495 catchup=false;
21496 }
21497
21498 99 box_out("Reading Weapons...");
21499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21500
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21501 99 box_out("okay.");
21502 99 box_eol();
21503 99 break;
21504
21505 case ID_COLORS:
21506
21507 //misc. colors
21508
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21509 {
21510 box_out("found.");
21511 box_eol();
21512 catchup=false;
21513 }
21514
21515 96 box_out("Reading Misc. Colors...");
21516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21517
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21518 96 box_out("okay.");
21519 96 box_eol();
21520 96 break;
21521
21522 case ID_ICONS:
21523
21524 //game icons
21525
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21526 {
21527 box_out("found.");
21528 box_eol();
21529 catchup=false;
21530 }
21531
21532 96 box_out("Reading Game Icons...");
21533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21534
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21535 96 box_out("okay.");
21536 96 box_eol();
21537 96 break;
21538
21539 case ID_INITDATA:
21540
21541 //initialization data
21542
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21543 {
21544 box_out("found.");
21545 box_eol();
21546 catchup=false;
21547 }
21548
21549 99 box_out("Reading Init. Data...");
21550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21551
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21552 99 box_out("okay.");
21553 99 box_eol();
21554
21555
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21556 {
21557
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 16 times.
99 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21558 {
21559 16 setupsubscreens();
21560
21561
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<MAXDMAPS; ++i)
21562 {
21563 8192 int32_t type=DMaps[i].type&dmfTYPE;
21564
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8131 times.
8192 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21565 8192 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21566 8192 }
21567 16 }
21568 99 }
21569
21570
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_sfx))
21571 {
21572 99 setupsfx();
21573 99 }
21574
21575
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21576 {
21577 99 init_item_drop_sets();
21578 99 }
21579
21580
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_favorites))
21581 {
21582 99 init_favorites();
21583 99 }
21584
21585 99 break;
21586
21587 case ID_GUYS:
21588
21589 //guys
21590
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21591 {
21592 box_out("found.");
21593 box_eol();
21594 catchup=false;
21595 }
21596
21597 99 box_out("Reading Custom Guy Data...");
21598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21599
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21600 99 box_out("okay.");
21601 99 box_eol();
21602 99 break;
21603
21604 case ID_HEROSPRITES:
21605
21606 //player sprites
21607
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21608 {
21609 box_out("found.");
21610 box_eol();
21611 catchup=false;
21612 }
21613
21614 96 box_out("Reading Custom Player Sprite Data...");
21615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21616
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21617 96 box_out("okay.");
21618 96 box_eol();
21619 96 break;
21620
21621 case ID_SUBSCREEN:
21622
21623 //custom subscreens
21624
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21625 {
21626 box_out("found.");
21627 box_eol();
21628 catchup=false;
21629 }
21630
21631 96 box_out("Reading Custom Subscreen Data...");
21632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21633
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21634 96 box_out("okay.");
21635 96 box_eol();
21636 96 break;
21637
21638 case ID_FFSCRIPT:
21639
21640 //Freeform combo scripts
21641
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21642 {
21643 box_out("found.");
21644 box_eol();
21645 catchup=false;
21646 }
21647
21648 96 box_out("Reading FF Script Data...");
21649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21650
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21651 96 box_out("okay.");
21652 96 box_eol();
21653 96 break;
21654
21655 case ID_SFX:
21656
21657 //SFX data
21658
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21659 {
21660 box_out("found.");
21661 box_eol();
21662 catchup=false;
21663 }
21664
21665 96 box_out("Reading SFX Data...");
21666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21667
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21668 96 box_out("okay.");
21669 96 box_eol();
21670 96 break;
21671
21672 case ID_MIDIS:
21673
21674 //midis
21675
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21676 {
21677 box_out("found.");
21678 box_eol();
21679 catchup=false;
21680 }
21681
21682 99 box_out("Reading Tunes...");
21683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21684
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21685 99 box_out("okay.");
21686 99 box_eol();
21687 99 break;
21688
21689 case ID_CHEATS:
21690
21691 //cheat codes
21692
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21693 {
21694 box_out("found.");
21695 box_eol();
21696 catchup=false;
21697 }
21698
21699 99 box_out("Reading Cheat Codes...");
21700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21701
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21702 99 box_out("okay.");
21703 99 box_eol();
21704 99 break;
21705
21706 case ID_ITEMDROPSETS:
21707
21708 //item drop sets
21709
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21710 {
21711 box_out("found.");
21712 box_eol();
21713 catchup=false;
21714 }
21715
21716 96 box_out("Reading Item Drop Sets...");
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21718
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21719 96 box_out("okay.");
21720 96 box_eol();
21721 96 break;
21722
21723 case ID_FAVORITES:
21724
21725 //favorite combos and combo aliases
21726
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21727 {
21728 box_out("found.");
21729 box_eol();
21730 catchup=false;
21731 }
21732
21733 96 box_out("Reading Favorite Combos...");
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21735
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21736 96 box_out("okay.");
21737 96 box_eol();
21738 96 break;
21739
21740 default:
21741 if(!catchup)
21742 {
21743 box_out("Bad token! Searching...");
21744 box_eol();
21745 }
21746
21747 catchup=true;
21748 break;
21749 }
21750
21751
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
2349 if(catchup)
21753 {
21754 //section id
21755 section_id=(section_id<<8);
21756
21757 if(!p_getc(&tempbyte,f,true))
21758 {
21759 return qe_invalid;
21760 }
21761
21762 section_id+=tempbyte;
21763 }
21764
21765 else
21766 {
21767 //section id
21768
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2250 times.
2349 if(!pack_feof(f))
21769 {
21770
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if(!p_mgetl(&section_id,f,true))
21771 {
21772 return qe_invalid;
21773 }
21774 2250 }
21775 }
21776 }
21777 99 }
21778 else
21779 {
21780 //rules
21781 box_out("Reading Rules...");
21782 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21783 checkstatus(ret);
21784 box_out("okay.");
21785 box_eol();
21786
21787 //strings
21788 box_out("Reading Strings...");
21789 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21790 checkstatus(ret);
21791 box_out("okay.");
21792 box_eol();
21793
21794 //door combo sets
21795 box_out("Reading Doors...");
21796 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21797 checkstatus(ret);
21798 box_out("okay.");
21799 box_eol();
21800
21801 //dmaps
21802 box_out("Reading DMaps...");
21803 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21804 checkstatus(ret);
21805 box_out("okay.");
21806 box_eol();
21807
21808 // misc data
21809 box_out("Reading Misc. Data...");
21810 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21811 checkstatus(ret);
21812 box_out("okay.");
21813 box_eol();
21814
21815 //items
21816 box_out("Reading Items...");
21817 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21818 checkstatus(ret);
21819 box_out("okay.");
21820 box_eol();
21821
21822 //weapons
21823 box_out("Reading Weapons...");
21824 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21825 checkstatus(ret);
21826 box_out("okay.");
21827 box_eol();
21828
21829 //guys
21830 box_out("Reading Custom Guy Data...");
21831 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21832 checkstatus(ret);
21833 box_out("okay.");
21834 box_eol();
21835
21836 //maps
21837 box_out("Reading Maps...");
21838 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21839 mapsread=true;
21840 checkstatus(ret);
21841 box_out("okay.");
21842 box_eol();
21843
21844 //combos
21845 box_out("Reading Combos...");
21846 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21847 combosread=true;
21848 checkstatus(ret);
21849 box_out("okay.");
21850 box_eol();
21851
21852 //color data
21853 box_out("Reading Color Data...");
21854 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21855 checkstatus(ret);
21856 box_out("okay.");
21857 box_eol();
21858
21859 //tiles
21860 box_out("Reading Tiles...");
21861 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21862 checkstatus(ret);
21863 box_out("okay.");
21864 box_eol();
21865
21866 //midis
21867 box_out("Reading Tunes...");
21868 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21869 checkstatus(ret);
21870 box_out("okay.");
21871 box_eol();
21872
21873 //cheat codes
21874 box_out("Reading Cheat Codes...");
21875 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21876 checkstatus(ret);
21877 box_out("okay.");
21878 box_eol();
21879
21880 //initialization data
21881 box_out("Reading Init. Data...");
21882 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21883 checkstatus(ret);
21884 box_out("okay.");
21885 box_eol();
21886
21887 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21888 {
21889 setupsubscreens();
21890
21891 for(int32_t i=0; i<MAXDMAPS; ++i)
21892 {
21893 int32_t type=DMaps[i].type&dmfTYPE;
21894 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21895 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21896 }
21897 }
21898
21899 box_out("Setting Up Default Sound Effects...");
21900
21901 if(keepall&&!get_bit(skip_flags, skip_sfx))
21902 setupsfx();
21903
21904 box_out("okay.");
21905 box_eol();
21906
21907 //player sprites
21908 box_out("Reading Custom Player Sprite Data...");
21909 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
21910 checkstatus(ret);
21911 box_out("okay.");
21912 box_eol();
21913
21914 box_out("Setting Up Default Item Drop Sets...");
21915 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21916 box_out("okay.");
21917 box_eol();
21918 }
21919
21920 99 init_spritelists();
21921
21922 // check data
21923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(f)
21924 {
21925 99 pack_fclose(f);
21926 99 }
21927
21928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!oldquest)
21929 {
21930
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(exists(tmpfilename))
21931 {
21932 delete_file(tmpfilename);
21933 }
21934 99 }
21935
21936
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(fixffcs && combosread && mapsread)
21937 {
21938 for(int32_t i=0; i<map_count; i++)
21939 {
21940 for(int32_t j=0; j<MAPSCRS; j++)
21941 {
21942 for(int32_t m=0; m<32; m++)
21943 {
21944 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
21945 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
21946 }
21947 }
21948 }
21949 }
21950
21951
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 18 times.
99 if(get_bit(quest_rules, qr_CONTFULL_DEP))
21952 {
21953 18 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
21954 18 set_bit(zinit.misc, idM_CONTPERCENT, 1);
21955 18 zinit.cont_heart=100;
21956 18 zinit.start_heart=zinit.hc;
21957 18 }
21958
21959 99 box_out("Done.");
21960 99 box_eol();
21961 99 box_end(false);
21962
21963 // if (keepall==true||!get_bit(skip_flags, skip_header))
21964
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_header))
21965 {
21966 99 memcpy(Header, &tempheader, sizeof(tempheader));
21967 99 }
21968
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_zinfo))
21969 {
21970 99 ZI.copyFrom(tempzi);
21971 99 }
21972
21973
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_maps))
21974 {
21975 map_count=old_map_count;
21976 }
21977
21978
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_rules))
21979 {
21980 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
21981 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
21982 }
21983
21984
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_midis))
21985 {
21986 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
21987 }
21988
21989
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(deletefilename[0] && exists(deletefilename))
21990 {
21991 99 delete_file(deletefilename);
21992 99 }
21993
21994 //Debug FFCore.quest_format[]
21995 99 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
21996 99 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
21997 99 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
21998 99 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
21999 99 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22000 99 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22001 99 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22002 99 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22003 99 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22004 99 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22005 99 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22006 99 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22007 99 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22008 99 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22009 99 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22010 99 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22011 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22012 99 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22013 99 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22014 99 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22015 99 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22016 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22017 99 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22018 99 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22019 99 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22020 99 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22021 99 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22022 99 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22023 99 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22024 99 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22025 //Print metadata for versions under 2.10 here. Bleah.
22026
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if( FFCore.quest_format[vZelda] < 0x210 )
22027 {
22028 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22029
22030 switch(FFCore.quest_format[vZelda])
22031 {
22032 case 0x193:
22033 {
22034 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22035 }
22036 case 0x192:
22037 {
22038 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22039 }
22040 case 0x190:
22041 {
22042 zprint2("Last saved in ZC Editor Version: 1.90");
22043 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22044 else zprint2("\n");
22045 break;
22046 }
22047 case 0x188:
22048 {
22049 zprint2("Last saved in ZC Editor Version: 1.88");
22050 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22051 else zprint2("\n");
22052 break;
22053 }
22054 case 0x187:
22055 {
22056 zprint2("Last saved in ZC Editor Version: 1.87");
22057 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22058 else zprint2("\n");
22059 break;
22060 }
22061 case 0x186:
22062 {
22063 zprint2("Last saved in ZC Editor Version: 1.86");
22064 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22065 else zprint2("\n");
22066 break;
22067 }
22068 case 0x185:
22069 {
22070 zprint2("Last saved in ZC Editor Version: 1.85");
22071 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22072 else zprint2("\n");
22073 break;
22074 }
22075 case 0x184:
22076 {
22077 zprint2("Last saved in ZC Editor Version: 1.84");
22078 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22079 else zprint2("\n");
22080 break;
22081 }
22082 case 0x183:
22083 {
22084 zprint2("Last saved in ZC Editor Version: 1.83");
22085 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22086 else zprint2("\n");
22087 break;
22088 }
22089 case 0x182:
22090 {
22091 zprint2("Last saved in ZC Editor Version: 1.82");
22092 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22093 else zprint2("\n");
22094 break;
22095 }
22096 case 0x181:
22097 {
22098 zprint2("Last saved in ZC Editor Version: 1.81");
22099 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22100 else zprint2("\n");
22101 break;
22102 }
22103 case 0x180:
22104 {
22105 zprint2("Last saved in ZC Editor Version: 1.80");
22106 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22107 else zprint2("\n");
22108 break;
22109 }
22110 default:
22111 {
22112 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22113 }
22114 }
22115 }
22116
22117 99 return qe_OK;
22118
22119 invalid:
22120 box_out("error.");
22121 box_eol();
22122 box_end(true);
22123
22124 if(f)
22125 {
22126 pack_fclose(f);
22127 }
22128
22129 if(!oldquest)
22130 {
22131 if(exists(tmpfilename))
22132 {
22133 delete_file(tmpfilename);
22134 }
22135
22136 if(deletefilename[0] && exists(deletefilename))
22137 {
22138 delete_file(deletefilename);
22139 }
22140 }
22141
22142 return qe_invalid;
22143
22144 99 }
22145
22146 99 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22147 {
22148 99 loading_qst_name = filename;
22149 99 loading_qst_num = qst_num;
22150 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22151 // So to avoid a more-recently update .qst file from hitting the "last saved in a newer version" prompt, we disable for replaying.
22152
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (!replay_is_replaying())
22153 loadquest_report = report;
22154 99 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22155 99 load_tmp_zi = NULL;
22156 99 loading_qst_name = NULL;
22157 99 loadquest_report = false;
22158 99 loading_qst_num = 0;
22159 99 return ret;
22160 }
22161 /*** end of qst.cc ***/
22162
22163